Setup GitHub action to deploy site to core cloud s3 bucket #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Core Cloud | |
on: | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
id-token: write | |
actions: read | |
env: | |
CYPRESS_TEST_URL: localhost | |
CYPRESS_TEST_PORT: 8080 | |
jobs: | |
s3-sync: | |
name: Build and sync to S3 | |
environment: | |
name: core-cloud | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.sha }} | |
- name: Configure AWS IdP Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/${{ vars.AWS_DEPLOYMENT_ROLE }} | |
role-session-name: GitHubActions | |
retry-max-attempts: 5 | |
aws-region: eu-west-2 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
- name: Build & Run Cypress Tests | |
uses: cypress-io/github-action@v6 | |
with: | |
browser: chrome | |
build: npm run build | |
start: npm run serve -- --port ${{ env.CYPRESS_TEST_PORT }} | |
wait-on: 'http://${{ env.CYPRESS_TEST_URL }}:${{ env.CYPRESS_TEST_PORT }}' | |
config: 'video=false,screenshotOnRunFailure=false' | |
env: | |
CYPRESS_TEST_URL: ${{ env.CYPRESS_TEST_URL }} | |
CYPRESS_TEST_PORT: ${{ env.CYPRESS_TEST_PORT }} | |
- name: Sync | |
working-directory: ./_site | |
run: | | |
aws s3 sync . s3://${{ vars.S3_BUCKET_NAME }}/ --delete |