[FRONTEND] Build #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: "[FRONTEND] Build" | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "`x.y.z-front.NN` 형태로 버전을 입력해주세요. (ex. 0.1.0-front.05)" | |
required: true | |
default: 0.0.1-front.00 | |
env: | |
TAG: ${{ github.event.inputs.tag }} | |
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}} | |
FRONTEND_ECR_REPOSITORY: ${{ secrets.FRONTEND_ECR_REPOSITORY }} | |
BUILD_PATH: "~/humancat-frontend-build-tmp" | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
condition_check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: check tag format | |
run: | | |
if [[ !(${{ env.TAG }} =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\-front\.[0-9]{2}$) ]]; | |
then | |
echo "You entered an incorrect tag format." | |
exit 1 | |
fi | |
- name: notice when job fails | |
if: failure() | |
uses: 8398a7/[email protected] | |
with: | |
status: ${{job.status}} | |
fields: repo,workflow,job | |
author_name: Github Action Slack | |
tagging: | |
needs: condition_check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Create Tag | |
run: | | |
git tag ${{ env.TAG }} | |
git push origin ${{ env.TAG }} | |
- name: notice when job fails | |
if: failure() | |
uses: 8398a7/[email protected] | |
with: | |
status: ${{job.status}} | |
fields: repo,workflow,job | |
author_name: Github Action Slack | |
build: | |
needs: tagging | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Move Python Sample code | |
run: | | |
mkdir -p $BUILD_PATH | |
cp -rf source/humancat-frontend/* $BUILD_PATH/ | |
cp -rf build/humancat-frontend/* $BUILD_PATH/ | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.ASSUME_ROLE_ARN }} | |
aws-region: ap-northeast-2 | |
role-session-name: GithubActionSession | |
- id: build-image | |
name: Build and Tag Image | |
env: | |
FRONTEND_ECR_REPOSITORY: ${{ env.FRONTEND_ECR_REPOSITORY }} | |
IMAGE_TAG: ${{ env.TAG }} | |
run: | | |
docker build -t $FRONTEND_ECR_REPOSITORY:$IMAGE_TAG $BUILD_PATH/ | |
- id: login-ecr | |
name: Login to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@v1 | |
- id: push-image-to-aws-ecr | |
name: Push image to Amazon ECR | |
env: | |
FRONTEND_ECR_REPOSITORY: ${{ env.FRONTEND_ECR_REPOSITORY }} | |
IMAGE_TAG: ${{ env.TAG }} | |
run: | | |
docker push $FRONTEND_ECR_REPOSITORY:$IMAGE_TAG | |
- name: Notice when job fails | |
if: always() | |
uses: 8398a7/[email protected] | |
with: | |
status: ${{job.status}} | |
fields: repo,workflow,job | |
author_name: Github Action Slack | |