mirror of
https://github.com/fiso64/slsk-batchdl.git
synced 2024-12-21 22:12:42 +00:00
Add github action for publishing image
This commit is contained in:
parent
2381faf80c
commit
24a7709671
1 changed files with 81 additions and 0 deletions
81
.github/workflows/publishImage.yml
vendored
Normal file
81
.github/workflows/publishImage.yml
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
name: Publish Docker image to Dockerhub
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
# uncomment to auto build when commits are pushed to listed branches
|
||||
# branches:
|
||||
# - 'master'
|
||||
tags:
|
||||
- '*.*.*'
|
||||
# don't trigger if just updating docs
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- '.github/**'
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
name: Build and push container images
|
||||
if: ${{ github.event_name != 'pull_request' && (vars.GHCR_IMAGE_NAME != '' || vars.DOCKERHUB_IMAGE_NAME != '' ) }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- dockerfile: ./Dockerfile
|
||||
suffix: ''
|
||||
platforms: 'linux/amd64,linux/arm64'
|
||||
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# uncomment to enable dockerhub
|
||||
|
||||
# - name: Log in to Docker Hub
|
||||
# uses: docker/login-action@v3
|
||||
# with:
|
||||
# username: ${{ secrets.DOCKER_USERNAME }}
|
||||
# password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
# add to images list to enable dockerhub ${{ vars.DOCKERHUB_IMAGE_NAME }}
|
||||
images: |
|
||||
${{ vars.GHCR_IMAGE_NAME }}
|
||||
# generate Docker tags based on the following events/attributes
|
||||
# https://github.com/docker/metadata-action/issues/247#issuecomment-1511259674 for NOT is default branch, eventually
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}},suffix=${{ matrix.suffix }}
|
||||
type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }},suffix=${{ matrix.suffix }}
|
||||
type=semver,pattern={{version}},suffix=${{ matrix.suffix }}
|
||||
flavor: |
|
||||
latest=false
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ${{ matrix.dockerfile }}
|
||||
push: ${{ !env.ACT}}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: ${{ matrix.platforms }}
|
Loading…
Reference in a new issue