Skip to content

Commit 8eabc15

Browse files
author
bgauduch
committed
testing image push to gcr.io
1 parent d1604a2 commit 8eabc15

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

.github/workflows/push-latest.yml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: push-latest
33
# trigger on push to master
44
# only on Dockerfile related modifications
55
on:
6+
workflow_dispatch:
67
push:
78
branches:
89
- "master"
@@ -15,9 +16,8 @@ on:
1516
- ".github/workflows/push-latest.yml"
1617

1718
env:
18-
ORGANIZATION: "zenika"
19-
IMAGE_NAME: "terraform-azure-cli"
20-
IMAGE_TAG: "latest"
19+
IMAGE_NAME: "zenika/terraform-azure-cli"
20+
REGISTRY: ghcr.io
2121

2222
jobs:
2323
build_push_latest:
@@ -32,20 +32,41 @@ jobs:
3232
echo "AZ_VERSION=$(jq -r '.azcli_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV
3333
echo "TF_VERSION=$(jq -r '.tf_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV
3434
35-
- name: Build image
36-
run: docker image build . --file Dockerfile --build-arg TERRAFORM_VERSION=${TF_VERSION} --build-arg AZURE_CLI_VERSION=${AZ_VERSION} --tag $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
3741

38-
- name: Login to Docker Hub registry
39-
run: echo '${{ secrets.DOCKERHUB_PASS }}' | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
42+
- name: Extract metadata (tags, labels) for Docker
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
flavor: |
48+
latest=auto
49+
tags: |
50+
# set latest tag for default branch
51+
type=raw,value=latest,enable={{is_default_branch}}
4052
41-
- name: Push image to registry
42-
run: docker push $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG
53+
- name: Set up QEMU
54+
uses: docker/setup-qemu-action@v2
4355

44-
- name: Save image
45-
run: docker image save -o $IMAGE_NAME-$IMAGE_TAG.tar $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG
56+
- name: Set up Buildx
57+
id: buildx
58+
uses: docker/setup-buildx-action@v2
4659

47-
- name: Upload image artifact
48-
uses: actions/upload-artifact@v4
60+
- name: Build and push container images
61+
uses: docker/build-push-action@v4
4962
with:
50-
name: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_TAG }}
51-
path: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_TAG }}.tar
63+
context: .
64+
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386
65+
build-args: |
66+
TERRAFORM_VERSION=${{ env.TF_VERSION }}
67+
AWS_CLI_VERSION=${{ env.AWS_VERSION }}
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
push: true
71+
cache-from: type=gha
72+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)