Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
ci: add automatic release
Browse files Browse the repository at this point in the history
  • Loading branch information
martabal committed Nov 22, 2023
1 parent 2991921 commit 31854bc
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
name: Publish Release

on:
workflow_dispatch:
inputs:
tags:
description: "version"
required: true
required: false
type: string
release:
types:
- created
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build_docker_release:
Expand All @@ -17,16 +25,26 @@ jobs:
ref: "main"
fetch-depth: 0

- name: Release tag
id: releasetag
run: |
if [ -z "${{ inputs.tag }}" ]; then
latest_release_tag=$(curl -s "https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/latest" | jq -r .tag_name)
echo "release_tag=${latest_release_tag}" >> $GITHUB_ENV
else
echo "release_tag=${{ inputs.tag }}" >> $GITHUB_ENV
fi
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=latest,enable=true
type=sha
type=raw,value=${{ inputs.tags }}
type=raw,value=${{ steps.releasetag.outputs.release_tag }},enable=true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -40,19 +58,21 @@ jobs:
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./
platforms: linux/arm/v7,linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
push: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 31854bc

Please sign in to comment.