Skip to content

Commit ffa203b

Browse files
authored
Merge pull request #3 from VertaAI/ln/gha-nack
chore: move to GHA
2 parents 5195084 + 48cce2b commit ffa203b

File tree

4 files changed

+234
-6
lines changed

4 files changed

+234
-6
lines changed

.github/workflows/release.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
name: Release
22
on:
3-
push:
4-
tags:
5-
- v[0-9]+.[0-9]+.[0-9]+
3+
# Only run when this repo changes from private to public.
4+
# Already public = never
5+
public
6+
# push:
7+
# tags:
8+
# - v[0-9]+.[0-9]+.[0-9]+
69
jobs:
710
release:
811
runs-on: ubuntu-latest

.github/workflows/testing.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
name: Testing
22

33
on:
4-
- push
5-
- pull_request
4+
# Only run when this repo changes from private to public.
5+
# Already public = never
6+
public
7+
# - push
8+
# - pull_request
69

710
jobs:
811
build:

.github/workflows/verta-build.yaml

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
name: Build and Push
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
push:
7+
branches:
8+
- verta/main
9+
- 'release/*'
10+
11+
permissions:
12+
id-token: write # This is required for requesting the JWT
13+
contents: write # Read is required for actions/checkout, write is required to comment on commits
14+
statuses: write
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
env:
21+
VERTA_ECR_REGISTRY: "493416687123.dkr.ecr.us-east-1.amazonaws.com"
22+
23+
jobs:
24+
nats-boot-config:
25+
runs-on: ubuntu-latest
26+
27+
env:
28+
ECR_REPOSITORY: "493416687123.dkr.ecr.us-east-1.amazonaws.com/external/natsio/nats-boot-config"
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v3
33+
with:
34+
# need previous commit to find PR head commit info
35+
fetch-depth: 2
36+
37+
- name: Configure AWS credentials
38+
uses: aws-actions/configure-aws-credentials@v2
39+
with:
40+
role-to-assume: arn:aws:iam::493416687123:role/github-actions
41+
aws-region: us-east-1
42+
43+
- name: Login to Amazon ECR
44+
id: login-ecr
45+
uses: aws-actions/amazon-ecr-login@v1
46+
47+
- name: Get branch names
48+
id: branch_names
49+
uses: tj-actions/branch-names@v7
50+
51+
- name: Get docker image tag
52+
id: image_info
53+
run: |
54+
branch=$(echo ${{ steps.branch_names.outputs.current_branch }} | sed 's,/,_,g')
55+
# PRs checkout a merge of PR head with target. Branches checkout current head of branch.
56+
# When in a PR, use the PR head commit sha instead of the checkout commit sha.
57+
pr_sha="${{ github.event.pull_request.head.sha }}"
58+
sha=${pr_sha:-$GITHUB_SHA}
59+
sha_details=$(TZ=UTC git show -s --format=%cd--%h --date='format-local:%Y-%m-%dT%H-%M-%S' --abbrev=7 $sha)
60+
echo "sha=${sha}" >> $GITHUB_OUTPUT
61+
echo "tag=${branch}-${sha_details}" >> $GITHUB_OUTPUT
62+
63+
- name: Update commit status with Docker image status
64+
uses: ouzi-dev/commit-status-updater@v2
65+
with:
66+
name: "Tag: ${{ steps.image_info.outputs.tag }}"
67+
description: "Publishing..."
68+
69+
- name: Inspect image to see if it already exists
70+
id: should_publish
71+
run: |
72+
TARGETS=""
73+
docker manifest inspect $ECR_REPOSITORY:${{ steps.image_info.outputs.tag }} || TARGETS="nack"
74+
echo "targets=${TARGETS}" >> $GITHUB_OUTPUT
75+
76+
- name: Build and push Docker image to ECR
77+
uses: docker/build-push-action@v4
78+
if: "!(steps.should_publish.outputs.targets == '')"
79+
with:
80+
# context: .
81+
file: docker/nats-boot-config/Dockerfile
82+
push: true
83+
build-args: |
84+
VERSION=${{ steps.image_info.outputs.tag }}
85+
tags: |
86+
${{ env.ECR_REPOSITORY }}:${{ steps.image_info.outputs.tag }}
87+
88+
- name: Configure AWS credentials for us-west-2
89+
# external components should mirror every merge to verta/main
90+
if: startsWith( github.ref, 'refs/heads/release/' ) || ( github.ref == 'refs/heads/verta/main' )
91+
uses: aws-actions/configure-aws-credentials@v2
92+
with:
93+
role-to-assume: arn:aws:iam::493416687123:role/github-actions
94+
aws-region: us-west-2
95+
96+
- name: Login to Amazon ECR for us-west-2
97+
id: login-ecr-release
98+
if: startsWith( github.ref, 'refs/heads/release/' ) || ( github.ref == 'refs/heads/verta/main' )
99+
uses: aws-actions/amazon-ecr-login@v1
100+
101+
- name: Mirror Docker image to us-west-2
102+
id: mirror-release
103+
if: startsWith( github.ref, 'refs/heads/release/' ) || ( github.ref == 'refs/heads/verta/main' )
104+
shell: bash
105+
run: |
106+
export TARGET_REPOSITORY=${ECR_REPOSITORY/us-east-1/us-west-2}
107+
docker manifest inspect ${TARGET_REPOSITORY}:${{ steps.image_info.outputs.tag }} || \
108+
docker tag ${ECR_REPOSITORY}:${{ steps.image_info.outputs.tag }} ${TARGET_REPOSITORY}:${{ steps.image_info.outputs.tag }} && \
109+
docker push ${TARGET_REPOSITORY}:${{ steps.image_info.outputs.tag }}
110+
111+
- name: Create commit comment
112+
uses: peter-evans/commit-comment@v2
113+
if: "!(steps.should_publish.outputs.targets == '')"
114+
with:
115+
body: "Docker Tag: ${{ steps.image_info.outputs.tag }}"
116+
117+
- name: Update commit status with Docker image status
118+
uses: ouzi-dev/commit-status-updater@v2
119+
with:
120+
name: "Tag: ${{ steps.image_info.outputs.tag }}"
121+
url: "${{ github.server_url }}/${{ github.repository }}/commit/${{ steps.image_info.outputs.sha }}#comments"
122+
status: success
123+
124+
nats-server-config-reloader:
125+
runs-on: ubuntu-latest
126+
127+
env:
128+
ECR_REPOSITORY: "493416687123.dkr.ecr.us-east-1.amazonaws.com/external/natsio/nats-server-config-reloader"
129+
130+
steps:
131+
- name: Checkout repository
132+
uses: actions/checkout@v3
133+
with:
134+
# need previous commit to find PR head commit info
135+
fetch-depth: 2
136+
137+
- name: Configure AWS credentials
138+
uses: aws-actions/configure-aws-credentials@v2
139+
with:
140+
role-to-assume: arn:aws:iam::493416687123:role/github-actions
141+
aws-region: us-east-1
142+
143+
- name: Login to Amazon ECR
144+
id: login-ecr
145+
uses: aws-actions/amazon-ecr-login@v1
146+
147+
- name: Get branch names
148+
id: branch_names
149+
uses: tj-actions/branch-names@v7
150+
151+
- name: Get docker image tag
152+
id: image_info
153+
run: |
154+
branch=$(echo ${{ steps.branch_names.outputs.current_branch }} | sed 's,/,_,g')
155+
# PRs checkout a merge of PR head with target. Branches checkout current head of branch.
156+
# When in a PR, use the PR head commit sha instead of the checkout commit sha.
157+
pr_sha="${{ github.event.pull_request.head.sha }}"
158+
sha=${pr_sha:-$GITHUB_SHA}
159+
sha_details=$(TZ=UTC git show -s --format=%cd--%h --date='format-local:%Y-%m-%dT%H-%M-%S' --abbrev=7 $sha)
160+
echo "sha=${sha}" >> $GITHUB_OUTPUT
161+
echo "tag=${branch}-${sha_details}" >> $GITHUB_OUTPUT
162+
163+
# - name: Update commit status with Docker image status
164+
# uses: ouzi-dev/commit-status-updater@v2
165+
# with:
166+
# name: "Tag: ${{ steps.image_info.outputs.tag }}"
167+
# description: "Publishing..."
168+
169+
- name: Inspect image to see if it already exists
170+
id: should_publish
171+
run: |
172+
TARGETS=""
173+
docker manifest inspect $ECR_REPOSITORY:${{ steps.image_info.outputs.tag }} || TARGETS="nack"
174+
echo "targets=${TARGETS}" >> $GITHUB_OUTPUT
175+
176+
- name: Build and push Docker image to ECR
177+
uses: docker/build-push-action@v4
178+
if: "!(steps.should_publish.outputs.targets == '')"
179+
with:
180+
# context: .
181+
file: docker/nats-server-config-reloader/Dockerfile
182+
push: true
183+
build-args: |
184+
VERSION=${{ steps.image_info.outputs.tag }}
185+
tags: |
186+
${{ env.ECR_REPOSITORY }}:${{ steps.image_info.outputs.tag }}
187+
188+
- name: Configure AWS credentials for us-west-2
189+
# external components should mirror every merge to verta/main
190+
if: startsWith( github.ref, 'refs/heads/release/' ) || ( github.ref == 'refs/heads/verta/main' )
191+
uses: aws-actions/configure-aws-credentials@v2
192+
with:
193+
role-to-assume: arn:aws:iam::493416687123:role/github-actions
194+
aws-region: us-west-2
195+
196+
- name: Login to Amazon ECR for us-west-2
197+
id: login-ecr-release
198+
if: startsWith( github.ref, 'refs/heads/release/' ) || ( github.ref == 'refs/heads/verta/main' )
199+
uses: aws-actions/amazon-ecr-login@v1
200+
201+
- name: Mirror Docker image to us-west-2
202+
id: mirror-release
203+
if: startsWith( github.ref, 'refs/heads/release/' ) || ( github.ref == 'refs/heads/verta/main' )
204+
shell: bash
205+
run: |
206+
export TARGET_REPOSITORY=${ECR_REPOSITORY/us-east-1/us-west-2}
207+
docker manifest inspect ${TARGET_REPOSITORY}:${{ steps.image_info.outputs.tag }} || \
208+
docker tag ${ECR_REPOSITORY}:${{ steps.image_info.outputs.tag }} ${TARGET_REPOSITORY}:${{ steps.image_info.outputs.tag }} && \
209+
docker push ${TARGET_REPOSITORY}:${{ steps.image_info.outputs.tag }}
210+
211+
# - name: Create commit comment
212+
# uses: peter-evans/commit-comment@v2
213+
# if: "!(steps.should_publish.outputs.targets == '')"
214+
# with:
215+
# body: "Docker Tag: ${{ steps.image_info.outputs.tag }}"
216+
217+
# - name: Update commit status with Docker image status
218+
# uses: ouzi-dev/commit-status-updater@v2
219+
# with:
220+
# name: "Tag: ${{ steps.image_info.outputs.tag }}"
221+
# url: "${{ github.server_url }}/${{ github.repository }}/commit/${{ steps.image_info.outputs.sha }}#comments"
222+
# status: success

docker/nats-server-config-reloader/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FROM alpine:latest as osdeps
88
RUN apk add --no-cache ca-certificates
99

1010
FROM alpine:3.17
11-
RUN apk -U --no-cache upgrad
11+
RUN apk -U --no-cache upgrade
1212
COPY --from=build /go/src/nack/nats-server-config-reloader.docker /usr/local/bin/nats-server-config-reloader
1313
COPY --from=osdeps /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
1414

0 commit comments

Comments
 (0)