buildx #69
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
name: buildx | |
on: | |
workflow_dispatch: | |
# pull_request: | |
schedule: | |
- cron: '22 4 * * 0' | |
push: | |
branches: | |
- 'master' | |
env: | |
PLATFORMS: linux/amd64,linux/arm64 | |
jobs: | |
buildx: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # v3 | |
- name: Set up Buildx | |
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3 | |
- name: Set up variable repository name | |
run: echo "IMAGE_NAME=${{ github.repository }}" >> $GITHUB_ENV | |
- name: Initial Buildx | |
uses: docker/build-push-action@1ca370b3a9802c92e886402e0dd88098a2533b12 # v6 | |
with: | |
context: . | |
file: Containerfile | |
tags: ${{ env.IMAGE_NAME }}:testing | |
platforms: ${{ env.PLATFORMS }} | |
provenance: false | |
- name: Load Built Image and Get Variables | |
id: vars | |
run: | | |
docker buildx build \ | |
-f Containerfile \ | |
-t ${{ env.IMAGE_NAME }}:testing \ | |
--platform=linux/amd64 \ | |
--load \ | |
. | |
CID=$(docker run -d ${{ env.IMAGE_NAME }}:testing) | |
VER_FULL=$(docker exec $CID rpm -q --queryformat '%{VERSION}' zpa-connector) | |
echo "VER_FULL=$VER_FULL" >> $GITHUB_ENV | |
docker rm -f $CID | |
VER_MINOR=$(echo $VER_FULL | cut -d. -f-2) | |
echo "VER_MINOR=$VER_MINOR" >> $GITHUB_ENV | |
VER_MAJOR=$(echo $VER_FULL | cut -d. -f-1) | |
echo "VER_MAJOR=$VER_MAJOR" >> $GITHUB_ENV | |
- name: Login to ghcr.io | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Buildx and Push | |
uses: docker/build-push-action@1ca370b3a9802c92e886402e0dd88098a2533b12 # v6 | |
with: | |
context: . | |
file: Containerfile | |
tags: | | |
ghcr.io/${{ env.IMAGE_NAME }}:latest | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_FULL }} | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_MINOR }} | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_MAJOR }} | |
platforms: ${{ env.PLATFORMS }} | |
push: true | |
provenance: false |