Skip to content

Commit

Permalink
ci(action): use generative metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kariudo committed Feb 2, 2024
1 parent b812577 commit 309afb0
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,37 @@ on:
push:
branches:
- master
tags:
- 'v*'

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

jobs:
dockerbuildpush:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set a datetag variable
run: echo "DATETAG=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
- name: Create image from repository
run: docker build -t ghcr.io/${{ github.actor }}/homeassistant-discord-bot:latest -t ghcr.io/${{ github.actor }}/homeassistant-discord-bot:${{ env.DATETAG }} .
- name: Push image to GitHub Container Registry with date tag
run: docker push ghcr.io/${{ github.actor }}/homeassistant-discord-bot:${{ env.DATETAG }}
- name: Push image to GitHub Container Registry as latest
run: docker push ghcr.io/${{ github.actor }}/homeassistant-discord-bot:latest

- name: Extract metadata for the Docker image
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

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

0 comments on commit 309afb0

Please sign in to comment.