Skip to content

Release Docker

Release Docker #95

name: Release Docker
on:
workflow_run:
workflows: ["Docker build"]
branches: [main]
types:
- completed
permissions:
contents: write
packages: write
actions: read
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.67.0
id: version
env:
WITH_V: true
DEFAULT_BUMP: patch
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DRY_RUN: true
- name: Create release
uses: actions/github-script@v7
env:
RELEASE_TAG: ${{ steps.version.outputs.new_tag }}
with:
script: |
try {
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
} catch (error) {
core.setFailed(error.message);
}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
push: true
context: .
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ steps.version.outputs.new_tag }}
org.opencontainers.image.revision=${{ github.sha }}
tags: |
ghcr.io/${{ github.repository }}:latest