Skip to content

Commit

Permalink
setup push action
Browse files Browse the repository at this point in the history
  • Loading branch information
rwanyoike committed Oct 7, 2024
1 parent 351fa47 commit ecc3aa2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
name: "Docker Image CI"

on:
workflow_dispatch:
push:
branches: ["main"]
tags: ["v*.*"]
pull_request:
branches: ["main"]

env:
REGISTRY: "docker.io"
IMAGE_NAME: "${{ vars.DOCKERHUB_USERNAME }}/srb2kart-server"

jobs:
build:
runs-on: "ubuntu-latest"
Expand All @@ -14,7 +20,23 @@ jobs:
uses: "actions/checkout@v4"
- name: "Set up Docker Buildx"
uses: "docker/setup-buildx-action@v3"
- name: "Log into registry ${{ env.REGISTRY }}"
if: "github.event_name != 'pull_request'"
uses: "docker/login-action@v3"
with:
registry: "${{ env.REGISTRY }}"
username: "${{ vars.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_TOKEN }}"
- name: "Extract Docker metadata"
id: "meta"
uses: "docker/metadata-action@v5"
with:
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
- name: "Build the Docker image"
uses: "docker/build-push-action@v6"
with:
tags: "${{ github.repository }}:latest"
push: "${{ github.event_name != 'pull_request' }}"
tags: "${{ steps.meta.outputs.tags }}"
labels: "${{ steps.meta.outputs.labels }}"
cache-from: "type=registry,ref=${{ env.IMAGE_NAME }}:latest"
cache-to: "type=inline"

0 comments on commit ecc3aa2

Please sign in to comment.