-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: update pipeline to publish image publicly
- Loading branch information
Showing
1 changed file
with
38 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,45 @@ | ||
name: Build and publish a Docker image to ghcr.io | ||
on: | ||
name: Publish Docker image | ||
|
||
# publish on releases, e.g. v2.1.13 (image tagged as "2.1.13" - "v" prefix is removed) | ||
on: | ||
release: | ||
types: [ published ] | ||
|
||
# publish on pushes to the main branch (image tagged as "latest") | ||
push: | ||
branches: | ||
- master | ||
types: [published] | ||
|
||
jobs: | ||
docker_publish: | ||
runs-on: "ubuntu-20.04" | ||
|
||
push_to_registries: | ||
name: Push Docker image to multiple registries | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||
with: | ||
images: | | ||
my-docker-hub-namespace/my-docker-hub-repository | ||
ghcr.io/${{ github.repository }} | ||
# https://github.com/marketplace/actions/push-to-ghcr | ||
- name: Build and publish a Docker image for ${{ github.repository }} | ||
uses: macbre/push-to-ghcr@master | ||
- name: Build and push Docker images | ||
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | ||
with: | ||
image_name: ${{ github.repository }} # it will be lowercased internally | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# optionally push to the Docker Hub (docker.io) | ||
# docker_io_token: ${{ secrets.DOCKER_IO_ACCESS_TOKEN }} # see https://hub.docker.com/settings/security | ||
# customize the username to be used when pushing to the Docker Hub | ||
# docker_io_user: foobar # see https://github.com/macbre/push-to-ghcr/issues/14 | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |