ads #105
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: Upload S3 | |
on: | |
push: | |
branch: main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
AWS_REGION: us-west-2 | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
DISTRIBUTION_ID: ${{ secrets.DISTRIBUTION_ID }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Update Config | |
run: | | |
sed -i 's/http:\/\/localhost/https:\/\/blog.wtfender.com/g' config.yaml | |
sed -i 's/GOOGLE_TAG/${{secrets.GOOGLE_TAG}}/g' config.yaml | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: latest | |
- name: Hugo Build | |
run: | | |
hugo -d public | |
tar -czvf public.tar.gz ./public | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: public.tar.gz | |
path: public.tar.gz | |
- name: Setup Creds | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
role-session-name: github-actions | |
aws-region: us-west-2 | |
- name: S3 Upload | |
run: aws s3 sync public s3://$AWS_S3_BUCKET --follow-symlinks --delete | |
- name: Refresh CloudFront | |
run: aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*" |