Skip to content

Commit

Permalink
Add GitHub Action deployment (#1653)
Browse files Browse the repository at this point in the history
Add GitHub Action deployment

Add a deploy.yml file and connect it to the build_and_deploy workflow. Comment out the corresponding build_and_deploy from CircleCI. When the migration is complete, we can delete the commented out portions from the CircleCI config. I added the AWS credentials to the repo's secrets. I also set up branch name formatting where any '/' is replaced with '-' in order to match the CircleCI behavior.

J=SLAP-1816
TEST=manual

Observe the build and deploy in the Github Actions panel. Point the theme test site to the assets and see the page work correctly.
  • Loading branch information
cea2aj committed Jan 26, 2022
1 parent 6e519ad commit ab1078a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 35 deletions.
66 changes: 33 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,39 +215,39 @@ jobs:
cache-control: 'max-age=43200'
workflows:
version: 2
build_and_deploy:
jobs:
- build:
filters:
branches:
ignore:
- develop
- master
- /^support\/.*/
- /^hotfix\/.*/
- /^feature\/.*-i18n/
- /^release\/.*/
- unit_test:
requires:
- build
- headless_acceptance_test:
requires:
- build
- browserstack_acceptance_test:
requires:
- build
- useragent_acceptance_test:
requires:
- build
- translation_test:
requires:
- build
- deploy_branch:
requires:
- unit_test
- browserstack_acceptance_test
- useragent_acceptance_test
- headless_acceptance_test
# build_and_deploy:
# jobs:
# - build:
# filters:
# branches:
# ignore:
# - develop
# - master
# - /^support\/.*/
# - /^hotfix\/.*/
# - /^feature\/.*-i18n/
# - /^release\/.*/
# - unit_test:
# requires:
# - build
# - headless_acceptance_test:
# requires:
# - build
# - browserstack_acceptance_test:
# requires:
# - build
# - useragent_acceptance_test:
# requires:
# - build
# - translation_test:
# requires:
# - build
# - deploy_branch:
# requires:
# - unit_test
# - browserstack_acceptance_test
# - useragent_acceptance_test
# - headless_acceptance_test
build_and_deploy_i18n:
jobs:
- build_i18n:
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,35 @@ on:

jobs:
call_build:
uses: yext/answers-search-ui/.github/workflows/build.yml@dev/build-workflow
uses: ./.github/workflows/build.yml

call_unit_test:
uses: yext/answers-search-ui/.github/workflows/unit_test.yml@dev/build-workflow
uses: ./.github/workflows/unit_test.yml
needs: call_build

format_branch_name:
runs-on: ubuntu-latest
outputs:
formatted_branch: ${{ steps.vars.outputs.formatted_branch }}
steps:
- name: Format branch name # replace '/' with '-'
id: vars
run: |
FORMATTED_BRANCH="$(echo ${GITHUB_REF_NAME} | sed "s/\//-/g")"
echo $FORMATTED_BRANCH
echo ::set-output name=formatted_branch::${FORMATTED_BRANCH}
call_deploy:
needs:
- call_unit_test
- format_branch_name
uses: ./.github/workflows/deploy.yml
with:
directory: dev/${{ needs.format_branch_name.outputs.formatted_branch }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

concurrency:
group: ci-build-and-deploy-${{ github.ref }}-1
cancel-in-progress: true
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Deploy assets to AWS S3

on:
workflow_call:
inputs:
bucket:
required: false
type: string
default: answers
directory:
required: true
type: string
cache-control:
required: false
type: string
default: no-cache
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Download build-output artifact
uses: actions/download-artifact@v2
with:
name: build-output
path: dist/
- name: Configure 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-east-1
- name: Deploy to S3
run: |
aws s3 cp ./dist/ s3://assets.sitescdn.net/${{ inputs.bucket }}/${{ inputs.directory }} \
--acl public-read \
--recursive \
--cache-control ${{ inputs.cache-control }}

0 comments on commit ab1078a

Please sign in to comment.