-
Notifications
You must be signed in to change notification settings - Fork 12
94 lines (79 loc) · 2.99 KB
/
Copy pathdeploy-to-dev.yml
File metadata and controls
94 lines (79 loc) · 2.99 KB
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
name: Deploy Platform to Dev (GitOps)
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Run Linter
run: npm run lint
# Uncomment when unit tests are ready
# - name: Run unit tests
# run: npm run test:unit:ci
build-and-deploy:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
outputs:
image_tag: ${{ steps.set-outputs.outputs.image_tag }}
steps:
- name: Checkout Platform repository
uses: actions/checkout@v4
- 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: ${{ vars.AWS_REGION || 'us-east-1' }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: true
- name: Set image tag
id: set-outputs
run: |
echo "IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV
echo "image_tag=${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: openmeet-ecr/openmeet-platform
GIT_REVISION: ${{ github.sha }}
GIT_BRANCH: ${{ github.ref_name }}
run: |
echo "Building image with tag: $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
APP_VERSION=$(node -p "require('./package.json').version")
docker buildx build --load \
--build-arg APP_VERSION="${APP_VERSION}" \
--build-arg COMMIT_SHA="${GITHUB_SHA}" \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# Tag as latest for main branch
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
gitops-update:
needs: [build-and-deploy]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: ./.github/workflows/update-image-gitops.yml
with:
service_name: platform
image_tag: ${{ needs.build-and-deploy.outputs.image_tag }}
environment: dev
ecr_registry: 433321780850.dkr.ecr.us-east-1.amazonaws.com
ecr_repository: openmeet-ecr/openmeet-platform
commit_message: "GitOps: Update Platform to ${{ needs.build-and-deploy.outputs.image_tag }} from main branch"
secrets:
GH_PAT: ${{ secrets.GH_PAT_INFRASTRUCTURE }}