Skip to content

Use fetch-depth: 0 when updating main branch on release #33

Use fetch-depth: 0 when updating main branch on release

Use fetch-depth: 0 when updating main branch on release #33

Workflow file for this run

name: Release Docker image
on:
release:
types: [created]
push:
branches: [release/*]
env:
DOCKER_IMAGE: ghcr.io/kereis/traefik-certs-dumper
permissions:
contents: read
packages: write
jobs:
release:
name: Release normal (Docker)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare tags for normal build
id: docker_meta
uses: docker/[email protected]
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
latest=true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7
driver-opts: network=host
- name: Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Build image
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
context: .
file: ./docker/Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
release-alpine:
name: Release Alpine
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare tags for normal build
id: docker_meta
uses: docker/[email protected]
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=sha
type=semver,pattern={{version}},suffix=-alpine
type=semver,pattern={{major}}.{{minor}},suffix=-alpine
type=semver,pattern={{major}},suffix=-alpine
alpine
flavor: |
latest=false
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Build and publish image
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
context: .
file: ./alpine/Dockerfile
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
update-main-branch:
name: Update main (master) branch (by auto-release)
runs-on: ubuntu-latest
if: contains(github.event.release.name, 'auto-release')
needs:
- release
- release-alpine
permissions:
contents: write
env:
TAG: ${{ github.event.release.tag_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update master branch
id: update_master_branch
run: |
release_branch=release/$(echo "$TAG" | cut -d 'v' -f 2)
git checkout master
git merge origin/$release_branch
git push
echo "RELEASE_BRANCH=$release_branch" >> "$GITHUB_OUTPUT"
- name: Update develop branch
run: |
git checkout develop
git merge master
git push
- name: Delete release branch
env:
RELEASE_BRANCH: ${{ steps.update_master_branch.outputs.RELEASE_BRANCH }}
run: git push origin --delete $RELEASE_BRANCH