Skip to content

Commit

Permalink
test publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gvkhna committed Dec 14, 2023
1 parent 6ee8c80 commit 37ec6c5
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish Docker image

on:
pull_request:
push:
branches: [ "main"]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
if: github.event.pull_request.draft == false

runs-on: ubuntu-latest
env:
COMMIT_SHA: ${{ github.sha }}
IMAGE_URL: "ghcr.io/${{ github.repository }}"
PLATFORMS: "linux/amd64,linux/arm64"
DOCKERFILE_BUILD: "Dockerfile.build"
steps:
- name: Check out the repo
uses: actions/checkout@v3

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

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image (versioned)
if: github.event_name == 'push'
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.PLATFORMS }}
tags: "${{ env.IMAGE_URL }}:latest-${{ env.COMMIT_SHA }}"
file: ${{ env.DOCKERFILE_BUILD }}

- name: Build and push Docker image (tagged)
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name == 'push' }}
platforms: ${{ env.PLATFORMS }}
tags: "${{ env.IMAGE_URL }}/${{ github.repository }}:latest"
file: ${{ env.DOCKERFILE_BUILD }}

0 comments on commit 37ec6c5

Please sign in to comment.