Skip to content

Commit

Permalink
Update tagged build as well
Browse files Browse the repository at this point in the history
  • Loading branch information
loafoe committed Mar 24, 2023
1 parent 62f7a57 commit c296b58
Showing 1 changed file with 56 additions and 23 deletions.
79 changes: 56 additions & 23 deletions .github/workflows/docker_tagged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,63 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
-
name: Login to DockerHub
uses: docker/login-action@v2
- name: Checkout
uses: actions/checkout@v3

- name: Calculate Docker image tags
id: tags
env:
DOCKER_IMAGES: "ghcr.io/philips-labs/siderite"
run: |
case $GITHUB_REF in
refs/tags/*) VERSION=${GITHUB_REF#refs/tags/};;
refs/heads/*) VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g');;
refs/pull/*) VERSION=pr-${{ github.event.number }};;
*) VERSION=sha-${GITHUB_SHA::8};;
esac
TAGS=()
for image in $DOCKER_IMAGES; do
TAGS+=("${image}:${VERSION}")
if [[ "${{ github.event.repository.default_branch }}" == "$VERSION" ]]; then
TAGS+=("${image}:latest")
fi
done
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::$(IFS=,; echo "${TAGS[*]}")
echo ::set-output name=commit_hash::${GITHUB_SHA::8}
echo ::set-output name=build_date::$(git show -s --format=%cI)
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to HSDP Docker registry
uses: docker/login-action@v2
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
registry: docker.na1.hsdp.io
username: ${{ secrets.HSDP_DOCKER_USERNAME }}
password: ${{ secrets.HSDP_DOCKER_PASSWORD }}
-
name: Checkout repository
uses: actions/checkout@v3
install: true
version: latest
# TODO: Remove driver-opts once fix is released docker/buildx#386
driver-opts: image=moby/buildkit:master

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
- name: Set output
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
if: github.event_name == 'push'

- name: Git information
id: vars
shell: bash
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/*/}
echo ::set-output name=sha_short::$(git rev-parse --short HEAD)
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
-
name: Build and push
name: Build and push alpine
id: docker_build
uses: docker/build-push-action@v4
with:
Expand All @@ -45,7 +75,10 @@ jobs:
GIT_COMMIT=${{ steps.vars.outputs.sha_short }}
platforms: linux/amd64
push: true
tags: philipslabs/siderite:${{ steps.vars.outputs.tag }},docker.na1.hsdp.io/philipslabs/siderite:${{ steps.vars.outputs.tag }}
tags: ${{ steps.tags.outputs.tags }}
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
-
name: Build and push debian
id: docker_build_debian
Expand All @@ -57,7 +90,7 @@ jobs:
GIT_COMMIT=${{ steps.vars.outputs.sha_short }}
platforms: linux/amd64
push: true
tags: philipslabs/siderite:debian-${{ steps.vars.outputs.tag }},docker.na1.hsdp.io/philipslabs/siderite:debian-${{ steps.vars.outputs.tag }}
tags: ${{ steps.tags.outputs.tags }}-debian
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit c296b58

Please sign in to comment.