Skip to content

Commit

Permalink
Update docker-image.yml
Browse files Browse the repository at this point in the history
Trying some changes from Claude.
  • Loading branch information
yarons authored Nov 28, 2024
1 parent 4c2455e commit 3be9d8f
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
name: Pritunl-Zero and Bastion multiarch package

on:
workflow_dispatch:
inputs:
version:
type: string
description: Version without the v prefix
required: true
default: "1.0.3019.96"

default: "1.0.3292.11"
env:
BASE_IMAGE_NAME: pritunl-zero
BASTION_IMAGE_NAME: pritunl-bastion
PTZTAG: ${{ inputs.version }}

jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
Expand All @@ -22,37 +19,38 @@ jobs:
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Log in to registry
# This is where you will update the PAT to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and push image
run: |
BASE_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$BASE_IMAGE_NAME
BASTION_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$BASTION_IMAGE_NAME
# Change all uppercase to lowercase
BASE_IMAGE_ID=$(echo $BASE_IMAGE_ID | tr '[A-Z]' '[a-z]')
BASTION_IMAGE_ID=$(echo $BASTION_IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo BASE_IMAGE_ID=$BASE_IMAGE_ID
echo BASTION_IMAGE_ID=$BASTION_IMAGE_ID
echo VERSION=$VERSION
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name builder --driver docker-container --use
docker buildx inspect --bootstrap
docker buildx build --platform=linux/arm64,linux/amd64 . --file Dockerfile --build-arg PTZTAG=$PTZTAG --tag $BASE_IMAGE_ID:$PTZTAG --tag $BASE_IMAGE_ID:latest --push --label "runnumber=${GITHUB_RUN_ID}"
# Build and push Pritunl Zero image with specific version and latest tags
docker buildx build --platform=linux/arm64,linux/amd64 . --file Dockerfile \
--build-arg PTZTAG=$PTZTAG \
--tag $BASE_IMAGE_ID:$PTZTAG \
--tag $BASE_IMAGE_ID:latest \
--push \
--label "runnumber=${GITHUB_RUN_ID}"
# Build and push Bastion image with specific version and latest tags
cd bastion
docker buildx build --platform=linux/arm64,linux/amd64 . --file Dockerfile --tag $BASTION_IMAGE_ID:$PTZTAG --tag $BASE_IMAGE_ID:latest --push --label "runnumber=${GITHUB_RUN_ID}"
docker buildx build --platform=linux/arm64,linux/amd64 . --file Dockerfile \
--tag $BASTION_IMAGE_ID:$PTZTAG \
--tag $BASTION_IMAGE_ID:latest \
--push \
--label "runnumber=${GITHUB_RUN_ID}"

0 comments on commit 3be9d8f

Please sign in to comment.