Created
August 31, 2022 06:30
-
-
Save dudo/9870a7e2ba9968604f71760ddcb4796b to your computer and use it in GitHub Desktop.
GitHub Actions
This file contains hidden or 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
on: | |
push: | |
branches: | |
- master | |
name: Git Tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
check_version: | |
name: Check Version | |
runs-on: ubuntu-latest | |
outputs: | |
git_tag_name: ${{ steps.tag_check.outputs.git_tag_name }} | |
steps: | |
- uses: actions/checkout@v2 # https://github.com/actions/checkout | |
- uses: dudo/[email protected] | |
id: tag_check | |
with: | |
git_tag_prefix: v | |
push: | |
name: Push Tag & S3 | |
needs: check_version | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x] | |
steps: | |
- name: AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-west-1 | |
- name: Push Tag to GitHub | |
run: | | |
curl -s -H "Authorization: token ${GITHUB_TOKEN}" \ | |
-d "{\"ref\": \"refs/tags/${{needs.check_version.outputs.git_tag_name}}\", \"sha\": \"${GITHUB_SHA}\"}" \ | |
"https://api.github.com/repos/${GITHUB_REPOSITORY}/git/refs" | |
- uses: actions/checkout@v2 # https://github.com/actions/checkout | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/[email protected] | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install Packages | |
run: npm install | |
- name: Build | |
run: npm run build | |
- name: Copy files S3 | |
run: aws s3 sync ./dist s3://com.cardbinder.browse | |
- name: Invalidate cache | |
run: aws cloudfront create-invalidation --distribution-id DISTRIBUTION --paths "/index.html" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment