From ae9ae435b715b8d92eb6c976161d2bf85f6b9532 Mon Sep 17 00:00:00 2001 From: Tim Ittermann Date: Sat, 3 Aug 2024 18:33:25 +0200 Subject: [PATCH] feat: add correct release workflow --- .github/workflows/docker-description.yml | 19 ---------- .github/workflows/main.yml | 45 ++++++++++++++++-------- 2 files changed, 31 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/docker-description.yml diff --git a/.github/workflows/docker-description.yml b/.github/workflows/docker-description.yml deleted file mode 100644 index 30fa4cb..0000000 --- a/.github/workflows/docker-description.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Update Docker Hub Description -on: - push: - branches: - - main - paths: - - README.md - - .github/workflows/docker-description.yaml -jobs: - dockerHubDescription: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Docker Hub Description - uses: peter-evans/dockerhub-description@v3 - env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - DOCKERHUB_REPOSITORY: timia2109/simple-meal-plan diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ccaac4..529db2b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,21 +1,38 @@ -name: Docker Image Build and Publish +name: Release Docker Image on: push: - branches: - - main + tags: + - "v*" +env: + REGISTRY: ghcr.io jobs: - build: - runs-on: ubuntu-latest + build-docker-image: + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write steps: - - uses: actions/checkout@master - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Publish to Registry - uses: elgohr/Publish-Docker-Github-Action@v5 + - uses: actions/checkout@v4 + + - name: Docker Login + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker Metadata action + id: docker_metadata + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 with: - name: timia2109/simple-meal-plan - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - #platforms: linux/amd64,linux/arm64 + context: . + push: true + tags: ${{ steps.docker_metadata.outputs.tags }} + labels: ${{ steps.docker_metadata.outputs.labels }}