-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67d0009
commit 7041950
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build container image | ||
|
||
on: | ||
push: | ||
tags: | ||
- "[a-z-]+:[a-z0-9-]+" | ||
env: | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: extract image name and tag using bash parameter expansion | ||
run: | | ||
image_name=${GITHUB_REF_NAME#*:} | ||
image_tag=${GITHUB_REF_NAME%%:*} | ||
echo "image_name=$image_name" >> "$GITHUB_ENV" | ||
echo "image_tag=$image_tag" >> "$GITHUB_ENV" | ||
- uses: actions/checkout@v3 | ||
- uses: docker/setup-qemu-action@v2 | ||
- uses: docker/setup-buildx-action@v2 | ||
- uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker metadata | ||
id: metadata | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ format('ghcr.io/astriaorg/test-images-{0}', env.image_name) }} | ||
tags: | | ||
type=raw,value=${{env.image_tag}} | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
# this gets rid of the unknown/unknown image that is created without this setting | ||
# https://github.com/docker/build-push-action/issues/820#issuecomment-1455687416 | ||
provenance: false | ||
context: . | ||
file: ${{ format('Dockerfile.{0}', env.image_name) }} | ||
platforms: 'linux/amd64,linux/arm64' | ||
push: true | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} |