Repository navigation
104 lines (89 loc) · 3.03 KB
/
Copy pathpublish.yml
File metadata and controls
104 lines (89 loc) · 3.03 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
95
96
97
98
99
100
101
102
103
104
name: Publish
on:
workflow_dispatch:
inputs:
service:
description: "Service to build and push"
required: true
type: choice
options:
- both
- api
- web
permissions:
id-token: write
contents: read
env:
AWS_REGION: us-east-1
jobs:
publish-api:
if: inputs.service == 'api' || inputs.service == 'both'
runs-on: ubuntu-latest
environment: mainnet
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- uses: aws-actions/amazon-ecr-login@v2
id: ecr
- name: Check if image exists
id: check
run: |
if aws ecr describe-images --repository-name info-api --image-ids imageTag=${{ github.sha }} 2>/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- uses: docker/setup-buildx-action@v3
if: steps.check.outputs.exists == 'false'
- uses: docker/build-push-action@v6
if: steps.check.outputs.exists == 'false'
with:
context: .
file: apps/api/Dockerfile
push: true
tags: |
${{ steps.ecr.outputs.registry }}/info-api:${{ github.sha }}
${{ steps.ecr.outputs.registry }}/info-api:latest
cache-from: type=gha,scope=api
cache-to: type=gha,scope=api,mode=max
publish-web:
if: inputs.service == 'web' || inputs.service == 'both'
runs-on: ubuntu-latest
strategy:
matrix:
environment: [mainnet]
environment: ${{ matrix.environment }}
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- uses: aws-actions/amazon-ecr-login@v2
id: ecr
- name: Check if image exists
id: check
run: |
if aws ecr describe-images --repository-name info-web --image-ids imageTag=${{ matrix.environment }}-${{ github.sha }} 2>/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- uses: docker/setup-buildx-action@v3
if: steps.check.outputs.exists == 'false'
- uses: docker/build-push-action@v6
if: steps.check.outputs.exists == 'false'
with:
context: .
file: apps/web/Dockerfile
push: true
build-args: |
NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }}
tags: |
${{ steps.ecr.outputs.registry }}/info-web:${{ matrix.environment }}-${{ github.sha }}
${{ steps.ecr.outputs.registry }}/info-web:${{ matrix.environment }}-latest
cache-from: type=gha,scope=web-${{ matrix.environment }}
cache-to: type=gha,scope=web-${{ matrix.environment }},mode=max