π’ Production Pipeline #2
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: π’ Production Pipeline | |
run-name: π’ Production Pipeline | |
on: | |
push: | |
branches: | |
- main | |
env: | |
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} | |
jobs: | |
lint: | |
name: πͺ Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: π« Cancel Workflow Action | |
uses: styfle/cancel-workflow-action@0.12.1 | |
- name: β¬οΈ Check out repository code | |
uses: actions/checkout@v4.1.1 | |
- name: π© Set up Node | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version: "16" | |
cache: "npm" | |
- name: π₯ Download dependencies | |
run: npm ci | |
- name: π¬ Lint source code | |
run: npm run lint | |
typecheck: | |
name: πͺ Typecheck | |
runs-on: ubuntu-latest | |
steps: | |
- name: π« Cancel Workflow Action | |
uses: styfle/cancel-workflow-action@0.12.1 | |
- name: β¬οΈ Check out repository code | |
uses: actions/checkout@v4.1.1 | |
- name: π© Set up Node | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version: "16" | |
cache: "npm" | |
- name: π₯ Download dependencies | |
run: npm ci | |
- name: β Typecheck | |
run: npm run typecheck | |
test: | |
name: π§ͺ Test | |
needs: [lint, typecheck] | |
runs-on: ubuntu-latest | |
steps: | |
- name: π« Cancel Workflow Action | |
uses: styfle/cancel-workflow-action@0.12.1 | |
- name: β¬οΈ Check out repository code | |
uses: actions/checkout@v4.1.1 | |
- name: π© Set up Node | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version: "16" | |
cache: "npm" | |
- name: π₯ Download dependencies | |
run: npm ci | |
- name: π§ͺ Run tests | |
run: npm test -- --coverage | |
- name: π Upload test coverage folder as an artifact | |
uses: actions/upload-artifact@v4.3.1 | |
with: | |
name: coverage | |
path: ./coverage | |
build: | |
name: π¦ Build | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: π« Cancel Workflow Action | |
uses: styfle/cancel-workflow-action@0.12.1 | |
- name: β¬οΈ Check out repository code | |
uses: actions/checkout@v4.1.1 | |
- name: π© Set up Node | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version: "16" | |
cache: "npm" | |
- name: π₯ Download dependencies | |
run: npm ci | |
- name: ποΈ Build App | |
run: npm run build | |
- name: β¬οΈ Upload production build as an artifact | |
uses: actions/upload-artifact@v4.3.1 | |
with: | |
name: build | |
path: ./build | |
deploy: | |
name: π’ Deploy to Production | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: π« Cancel Workflow Action | |
uses: styfle/cancel-workflow-action@0.12.1 | |
- name: β¬οΈ Check out repository code | |
uses: actions/checkout@v4.1.1 | |
- name: π© Set up Node | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version: "16" | |
cache: "npm" | |
- name: π₯ Download dependencies | |
run: npm ci | |
- name: β¬οΈ Download production build artifact | |
uses: actions/download-artifact@v4.1.4 | |
- name: π Display structure of build directory | |
run: ls -l | |
working-directory: build | |
- name: π€ Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4.0.2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: π’ Deploy (Sync build folder to the production bucket with the AWS CLI) | |
run: | | |
aws s3 sync ./build s3://$AWS_S3_BUCKET_NAME |