Skip to content

Commit

Permalink
Automatic releases
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleplus committed Mar 15, 2024
1 parent c7311be commit 40eb8f0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
- cron: '0 0 * * 0'
workflow_dispatch:

permissions: {}
permissions:
contents: write

jobs:
build:
Expand Down Expand Up @@ -48,3 +49,18 @@ jobs:
- name: Test the Docker image
working-directory: ${{ env.IMAGE }}
run: docker compose -f docker-compose.test.yml run sut
- name: Set RELEASE
if: github.event_name != 'pull_request'
run: |
# shellcheck disable=SC2086
RC="$(\grep ${IMAGE}/Dockerfile -e '^FROM' | sed -e 's/^.*://')"
if [[ "${RC}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && ! git show-ref --tags --verify --quiet "refs/tags/v${RC}" ; then
echo "RELEASE=${RC}" >> "${GITHUB_ENV}"
fi
- name: Trigger release
if: env.RELEASE == true
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: v${{ env.RELEASE }}
43 changes: 43 additions & 0 deletions .github/workflows/dockerrealase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Docker Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set IMAGE
run: echo "IMAGE=${GITHUB_REPOSITORY#*/docker-}" >> "${GITHUB_ENV}"
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ github.repository_owner }}/${{ env.IMAGE }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
context: ${{ env.IMAGE }}
platforms: linux/amd64,linux/arm64
pull: true
push: true
sbom: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 40eb8f0

Please sign in to comment.