Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsharp committed Aug 4, 2024
1 parent c86ceed commit 2440ff3
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions .github/workflows/docker-main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Docker Image
name: Build and Push Docker Image

on:
workflow_dispatch:
Expand All @@ -15,52 +15,39 @@ jobs:
uses: actions/checkout@v4

- name: Prepare Tags
id: prep
id: tags
run: |
DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/}
VERSION=${GITHUB_REF##*/}
# If this is the main branch, use 'latest' instead
if [[ $GITHUB_REF == refs/heads/main ]]; then
if [[ $VERSION == main ]]; then
VERSION=latest
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
# If the version is a version number, also tag with 'latest'
if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
# Tag with the GitHub run id to create a unique tag for this run
TAGS="$TAGS,${DOCKER_IMAGE}:${GITHUB_RUN_ID}"
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${GITHUB_RUN_ID}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
with:
platforms: all

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

- name: Login to Docker
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/amd64, linux/arm64
platforms: linux/amd64
push: true
tags: ${{ steps.prep.outputs.tags }}
tags: ${{ steps.tags.outputs.tags }}

0 comments on commit 2440ff3

Please sign in to comment.