Merge branch 'master' into release/next #518
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: CI | |
on: | |
push: | |
branches: | |
- master | |
- release/* | |
- dev/* | |
- qa/* | |
- cluster/* | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- master | |
- release/* | |
- dev/* | |
- qa/* | |
- cluster/* | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: config | |
run: cp ini/config.ini.ci ini/config.ini | |
- name: install | |
run: npm install | |
- name: inject commit sha | |
run: sed -i 's/\$\$GITHUB_SHA\$\$/'"${GITHUB_SHA}"'/' public/index.html | |
- name: build | |
# circular dependencies are currently throwing warnings | |
run: CI=false npm run build | |
- name: tar | |
run: tar -zcvf build.tar.gz ./build | |
- name: save artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build.tar.gz | |
path: build.tar.gz | |
image: | |
runs-on: ubuntu-20.04 | |
needs: build | |
if: github.event_name != 'pull_request' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Fetch artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: build.tar.gz | |
- name: unpack | |
run: tar -zxvf build.tar.gz && ls -l | |
- name: set docker env (branch non PR) | |
if: github.ref_type == 'branch' && github.event_name != 'pull_request' | |
shell: bash | |
run: | | |
echo "REF_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / _)" >> $GITHUB_ENV | |
echo "ECR_REPO=cbidb-staff-web-snapshot" >> $GITHUB_ENV | |
- name: set docker env (branch PR) | |
if: github.ref_type == 'branch' && github.event_name == 'pull_request' | |
shell: bash | |
run: | | |
echo "REF_NAME=$(echo ${GITHUB_HEAD_REF} | tr / _)" >> $GITHUB_ENV | |
echo "ECR_REPO=cbidb-staff-web-snapshot" >> $GITHUB_ENV | |
- name: set docker env (tag) | |
if: github.ref_type == 'tag' | |
shell: bash | |
run: | | |
echo "REF_NAME=$(echo ${GITHUB_REF#refs/tags/} | tr / _ | sed 's/^v//g')" >> $GITHUB_ENV | |
echo "ECR_REPO=cbidb-staff-web-release" >> $GITHUB_ENV | |
- name: echo vars | |
run: | | |
echo ${{ env.REF_NAME }} | |
echo ${{ env.ECR_REPO }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_ACCESS_TOKEN }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: build image | |
run: docker build -t ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ env.REF_NAME }} . | |
- name: tag & push aws | |
run: docker push ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ env.REF_NAME }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |