This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
82 lines (79 loc) · 2.95 KB
/
pr.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
name: Deployment to Staging
on:
issue_comment:
types:
- created
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Trigger deployment on comment
id: trigger-deployment
uses: shanegenschaw/[email protected]
with:
trigger: '@thewca-bot deploy staging'
reaction: rocket
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get ref from pr
id: comment-branch
uses: xt0rted/pull-request-comment-branch@v2
if: steps.trigger-deployment.outputs.triggered == 'true'
- name: Checkout `main` branch
uses: actions/checkout@v4
- name: Checkout PR branch
run: gh pr checkout $PR_NUMBER
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Get the SHA of the current branch/fork
shell: bash
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
if: steps.trigger-deployment.outputs.triggered == 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: steps.trigger-deployment.outputs.triggered == 'true'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.CI_CD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.CI_CD_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
if: steps.trigger-deployment.outputs.triggered == 'true'
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
if: steps.trigger-deployment.outputs.triggered == 'true'
- name: Build and push handler Image
if: steps.trigger-deployment.outputs.triggered == 'true'
uses: docker/build-push-action@v6
with:
context: .
push: true
file: dockerfile.handler
tags: |
${{ steps.login-ecr.outputs.registry }}/wca-registration-handler:staging
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_TAG=${{ env.SHORT_SHA }}
- name: Build and push worker Image
if: steps.trigger-deployment.outputs.triggered == 'true'
uses: docker/build-push-action@v6
with:
context: .
push: true
file: dockerfile.worker
tags: |
${{ steps.login-ecr.outputs.registry }}/wca-registration-worker:staging
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_TAG=${{ env.SHORT_SHA }}
- name: Deploy if triggered
if: steps.trigger-deployment.outputs.triggered == 'true'
env:
CLUSTER_NAME: wca-registration-staging
run: |
aws ecs update-service --cluster ${{ env.CLUSTER_NAME }} --service Staging-Service --force-new-deployment