Skip to content

Commit

Permalink
Merge pull request #583 from NYPL/SFR-2404/full-cicd
Browse files Browse the repository at this point in the history
SFR-2404: Implement full ci/cd workflow
  • Loading branch information
jackiequach authored Jan 9, 2025
2 parents c073b46 + 7d437a1 commit 9d4bb0a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/Playwright.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Playwright Tests for Digital Research Books

on:
workflow_call:
inputs:
base_url:
description: "Base URL for environment"
default: "http://local.nypl.org:3000/"
required: false
type: string
pull_request:

jobs:
Expand All @@ -17,8 +24,8 @@ jobs:

- name: Set environment for branch
run: |
if [[ $GITHUB_REF_NAME == 'production' ]]; then
echo "BASE_URL=https://drb-qa.nypl.org/" >> "$GITHUB_ENV"
if [[ github.event.inputs.base_url != '' ]]; then
echo "BASE_URL=${{ github.event.inputs.base_url }}" >> "$GITHUB_ENV"
else
echo "BASE_URL=http://local.nypl.org:3000/" >> "$GITHUB_ENV"
fi
Expand Down
33 changes: 11 additions & 22 deletions .github/workflows/build-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,33 @@
# build a container and deploy to ECR
name: Publish Production
on:
pull_request:
branches: [production]
types: [closed]
workflow_call:

jobs:
tag_release:
name: Tag and Release
# only run if PR is merged (not just closed)
if: github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# the tag will match the package.json version (eg. v1.0.0)
- name: Tag
id: autotagger
uses: butlerlogic/[email protected]
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
strategy: package
tag_prefix: v
# use the body of the PR commit as the tag message
tag_message: ${{ github.event.pull_request.body }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Release
id: create_release
if: steps.autotagger.outputs.tagname != ''
if: steps.tag_version.outputs.new_tag != ''
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.autotagger.outputs.tagname }}
name: ${{ steps.autotagger.outputs.tagname }}
# use the body of the PR commit as the release body
body: ${{ github.event.pull_request.body }}
tag_name: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
draft: false
prerelease: false

publish_qa:
name: Publish image to ECR
if: github.event.pull_request.merged
Expand Down Expand Up @@ -85,4 +74,4 @@ jobs:
- name: Force ECS Update
run: |
aws ecs update-service --cluster sfr-frontend-production-tf --service sfr-frontend-production-tf --force-new-deployment
aws ecs update-service --cluster sfr-frontend-production-tf --service sfr-frontend-production-tf --force-new-deployment
5 changes: 1 addition & 4 deletions .github/workflows/build-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
# build a container and deploy to ECR
name: Publish qa
on:
pull_request:
branches: [development]
types: [closed]
workflow_call:

jobs:
publish_qa:
name: Publish image to ECR
if: github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- name: checkout
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/full-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Full CI/CD Pipeline

on:
push:
branches: [main]

jobs:
# Job to deploy to the QA environment on successful merge to `main`
deploy_to_qa:
uses: NYPL/sfr-bookfinder-front-end/.github/workflows/build-qa.yml@main
secrets: inherit

# Job to run e2e tests on the QA environment after deployment
run_e2e_tests:
needs: deploy_to_qa
uses: NYPL/sfr-bookfinder-front-end/.github/workflows/Playwright.yml@main
with:
base_url: "https://drb-qa.nypl.org/"
secrets: inherit

# Job to deploy to production after successful e2e tests on QA
deploy_to_production:
needs: run_e2e_tests
uses: NYPL/sfr-bookfinder-front-end/.github/workflows/build-production.yaml@main
secrets: inherit
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Prerelease]

- Add new yml file for full ci/cd and auto bump version in prod release workflow

## [0.18.12]

- Update OptinMonster script
Expand Down

0 comments on commit 9d4bb0a

Please sign in to comment.