Skip to content

Commit 49013ac

Browse files
committed
Migrate to Quay.io and ECR
1 parent 406bf90 commit 49013ac

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

.github/workflows/build-push.yml

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

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ test: ## Run tests (dind)
1616
test-local: ## Run tests (local)
1717
./tests/runner.sh
1818

19+
_ci_test:
20+
true
21+
1922
clean: ## Remove built image
2023
docker rmi $(IMAGE_NAME):$(TAG)
2124

0 commit comments

Comments
 (0)