Skip to content

Commit

Permalink
ci: gha migration boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
skripted-io committed Oct 25, 2023
1 parent d2afc94 commit 056d027
Show file tree
Hide file tree
Showing 4 changed files with 1,397 additions and 70 deletions.
70 changes: 0 additions & 70 deletions .circleci/config.yml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CI/CD

on:
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
pull_request: # Runs whenever a pull request is created or updated
push: # Runs whenever a commit is pushed to the repository
branches: [master]

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

permissions:
contents: write # publish a GitHub release
pages: write # deploy to GitHub Pages
issues: write # comment on released issues
pull-requests: write # comment on released pull requests

jobs:
sync-s3:
runs-on: ubuntu-latest

permissions:
id-token: write
contents: read

env:
LEGACY_ACCOUNT_OIDC_ROLE: ${{ secrets.LEGACY_ACCOUNT_OIDC_ROLE }}
AWS_REGION: ${{ secrets.AWS_REGION }}
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
TRIGGER_DEPLOY: ${{ startsWith(github.ref, 'refs/heads/master') }}

steps:
- uses: actions/checkout@v4

- uses: wagoid/commitlint-github-action@v5
if: github.event_name == 'pull_request'

- uses: actions/setup-node@v3
with:
cache: "npm"
node-version-file: ".nvmrc"

- name: Info
run: |
cat <<EOF
Node version: $(node --version)
NPM version: $(npm --version)
GitHub ref: ${{ github.ref }}
GitHub head ref: ${{ github.head_ref }}
EOF
- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ env.LEGACY_ACCOUNT_OIDC_ROLE }}
aws-region: ${{ env.AWS_REGION }}

- name: Sync "resources" directory with S3
env:
S3_BUCKET_NAME: ${{ env.S3_BUCKET_NAME }}
run: |
aws s3 sync resources s3://${{ env.S3_BUCKET_NAME }} $([[ "$TRIGGER_DEPLOY" == "false" ]] && echo "--dryrun")
fastly-purge-all:
runs-on: ubuntu-latest
needs: sync-s3
if: github.ref == 'refs/heads/master'
env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_KEY }}
FASTLY_SERVICE_ID: ${{ secrets.FASTLY_SERVICE_ID }}
steps:
- uses: actions/checkout@v4

- name: Purge Fastly Cache
run: |
curl -X POST -H "Fastly-Key: ${{ secrets.FASTLY_API_TOKEN }}" https://api.fastly.com/service/${{ secrets.FASTLY_SERVICE_ID }}/purge_all
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16
Loading

0 comments on commit 056d027

Please sign in to comment.