-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (88 loc) · 2.85 KB
/
github-action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
on:
push:
release:
types: [published]
name: Docker Build and Push
env:
ECR_REGISTRY: 151345152001.dkr.ecr.ap-northeast-2.amazonaws.com
ECR_REPOSITORY: popo-admin-web
jobs:
lint:
name: Prettier and ESLint check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install -D
- name: Run Prettier
run: npm run format:check
- name: Run ESLint
run: npm run lint
docker_build_and_push:
name: Docker build and push
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64' # support AWS EC2 t4g
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
- name: Determine Prod/Dev Stage
run: |
if [[ ${{ github.event_name }} == 'release' ]]; then
echo "PROD"
echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
echo "NEXT_PUBLIC_ENV=prod" >> $GITHUB_ENV
else
echo "DEV"
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
echo "NEXT_PUBLIC_ENV=dev" >> $GITHUB_ENV
fi
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64 # support AWS EC2 t4g
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
build-args: |
"NEXT_PUBLIC_ENV=${{ env.NEXT_PUBLIC_ENV }}"
"POPO_VERSION=${{ github.event.release.tag_name || github.sha }}"
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
redeploy_dev_service:
name: Redeploy Dev Service
needs: docker_build_and_push
runs-on: ubuntu-latest
steps:
- name: Redeploy Dev Service
run: curl -X POST ${{ secrets.PORTAINER_DEV_SERVICE_WEBHOOK }}
deploy_health_check:
name: Check Application Status
needs: redeploy_dev_service
runs-on: ubuntu-latest
steps:
- name: Check the deployed service URL
uses: jtalk/url-health-check-action@v4
with:
url: https://admin.popo.poapper.club|https://admin.popo-dev.poapper.club
follow-redirect: true
max-attempts: 3
retry-delay: 10s