Skip to content

Commit

Permalink
Update build-and-publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
th0th committed Jan 14, 2024
1 parent 8f2db9d commit 78147a1
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
name: Publish Docker image

name: Build and publish
on:
create:
tags:
- '*'
push:
branches:
- main
tags:
- 'v*'

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
build:
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
- name: Log in to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Extract metadata for docker image
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: th0th/postgres-s3-backup,ghcr.io/th0th/postgres-s3-backup
images: |
ghcr.io/${{ github.repository }}
${{ github.repository }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 78147a1

Please sign in to comment.