deploy #6
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 | |
on: | |
workflow_run: | |
workflows: ["build"] | |
types: | |
- completed | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-region: eu-west-2 | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: release | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ github.token }} | |
- name: Unzip artifact for deployment | |
run: unzip release.zip | |
- name: Copy files to S3 | |
run: | | |
cd build/ | |
aws s3 sync . s3://${{ secrets.AWS_S3_BUCKET_NAME }} | |
- name: Invalidate CloudFront Cache | |
run: | | |
aws cloudfront create-invalidation \ | |
--distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} \ | |
--paths "/*" |