Skip to content

Commit

Permalink
update docker action
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Sep 10, 2024
1 parent 509ee66 commit e7f070a
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
name: Docker Image CI
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
name: build-and-upload-docker-image

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

jobs:

build:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
file: Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit e7f070a

Please sign in to comment.