Skip to content

Commit a4ba5a2

Browse files
committed
Migrate to Quay.io and ECR
1 parent c538a12 commit a4ba5a2

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

.github/workflows/build-push.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: build and push on main and tags
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v[0-9]+.[0-9]+.[0-9]+
9+
- v[0-9]+.[0-9]+.[0-9]+-[0-9]+
10+
pull_request:
11+
12+
env:
13+
GITHUB_ROLE_ARN: arn:aws:iam::461800378586:role/GitHubECRPublic
14+
15+
permissions:
16+
id-token: write # Required for OIDC
17+
contents: read # This is required for actions/checkout
18+
19+
jobs:
20+
build_and_push:
21+
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Get repo name
28+
id: image_name
29+
run: |
30+
sed -E -e 's/docker-//' -e 's/^/image_name=/' <<<"${{ github.repository }}" >> "$GITHUB_OUTPUT"
31+
32+
- name: Docker meta
33+
id: meta
34+
uses: docker/metadata-action@v4
35+
with:
36+
# list of Docker images to use as base name for tags
37+
images: |
38+
quay.io/${{ steps.image_name.outputs.image_name }}
39+
public.ecr.aws/${{ steps.image_name.outputs.image_name }}
40+
# generate Docker tags based on the following events/attributes
41+
tags: |
42+
# type=schedule
43+
type=ref,event=branch
44+
type=ref,event=pr
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
# type=sha
48+
49+
- name: Set up QEMU
50+
uses: docker/setup-qemu-action@v2
51+
52+
- name: Set up Docker Buildx
53+
id: buildx
54+
uses: docker/setup-buildx-action@v2
55+
56+
# The values provided to these two AWS steps are always the same for Panubo owned repos
57+
- name: Configure AWS Credentials
58+
uses: aws-actions/configure-aws-credentials@v1-node16
59+
with:
60+
role-to-assume: ${{ env.GITHUB_ROLE_ARN }}
61+
aws-region: us-east-1
62+
63+
- name: Login to ECR
64+
if: github.event_name != 'pull_request'
65+
uses: docker/login-action@v2
66+
with:
67+
registry: public.ecr.aws
68+
69+
- name: Login to Quay.io
70+
if: github.event_name != 'pull_request'
71+
uses: docker/login-action@v2
72+
with:
73+
registry: quay.io
74+
username: ${{ secrets.PANUBUILD_QUAYIO_USERNAME }}
75+
password: ${{ secrets.PANUBUILD_QUAYIO_TOKEN }}
76+
77+
# - name: Setup BATS
78+
# uses: mig4/setup-bats@v1
79+
# with:
80+
# bats-version: 1.7.0
81+
82+
- name: Build and export to Docker
83+
uses: docker/build-push-action@v4
84+
with:
85+
builder: ${{ steps.buildx.outputs.name }}
86+
cache-from: type=gha
87+
load: true
88+
tags: ${{ steps.image_name.outputs.image_name }}:test
89+
90+
# - name: Test
91+
# run: |
92+
# make _ci_test
93+
94+
- name: Build and Push
95+
uses: docker/build-push-action@v3
96+
with:
97+
builder: ${{ steps.buildx.outputs.name }}
98+
push: ${{ github.event_name != 'pull_request' }}
99+
cache-from: type=gha
100+
cache-to: type=gha,mode=max
101+
platforms: linux/amd64,linux/arm64
102+
tags: ${{ steps.meta.outputs.tags }}
103+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)