Skip to content

Commit d517eab

Browse files
authored
Isolate docker builds on tags (#26)
1 parent 7d19fca commit d517eab

File tree

3 files changed

+61
-66
lines changed

3 files changed

+61
-66
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Docker Build and Push Release Image
2+
3+
on:
4+
push:
5+
tags:
6+
- '0.*'
7+
8+
env:
9+
REGISTRY: docker.io
10+
IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/python-template
11+
12+
jobs:
13+
docker-build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Log in to Docker Hub
26+
uses: docker/login-action@v3
27+
with:
28+
username: ${{ secrets.DOCKER_USERNAME }}
29+
password: ${{ secrets.DOCKER_PASSWORD }}
30+
31+
- name: Extract version from tag
32+
id: tag_version
33+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
34+
35+
- name: Build and push RELEASE image
36+
uses: docker/build-push-action@v2
37+
with:
38+
context: .
39+
file: ./Dockerfile
40+
push: true
41+
tags: |
42+
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
43+
${{ env.IMAGE_NAME }}:stable
44+
platforms: linux/amd64,linux/arm64

.github/workflows/hotfix.yml

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313

1414
jobs:
1515
semantic-release:
16-
if: "!startsWith(github.ref, 'refs/tags/') && contains(github.event.head_commit.message, 'hotfix:')"
16+
if: contains(github.event.head_commit.message, 'hotfix:')
1717
permissions:
1818
contents: write # to be able to publish a GitHub release
1919
issues: write # to be able to comment on released issues
@@ -40,42 +40,8 @@ jobs:
4040
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4141
run: npx semantic-release
4242

43-
docker-build:
44-
if: startsWith(github.ref, 'refs/tags/')
45-
runs-on: ubuntu-latest
46-
needs: semantic-release
47-
steps:
48-
- name: Checkout repository
49-
uses: actions/checkout@v4
50-
51-
- name: Set up QEMU
52-
uses: docker/setup-qemu-action@v3
53-
54-
- name: Set up Docker Buildx
55-
uses: docker/setup-buildx-action@v3
56-
57-
- name: Log in to Docker Hub
58-
uses: docker/login-action@v3
59-
with:
60-
username: ${{ secrets.DOCKER_USERNAME }}
61-
password: ${{ secrets.DOCKER_PASSWORD }}
62-
63-
- name: Extract version from tag
64-
id: tag_version
65-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
66-
67-
- name: Build and push HOTFIX image
68-
uses: docker/build-push-action@v2
69-
with:
70-
context: .
71-
file: ./Dockerfile
72-
push: true
73-
tags: |
74-
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
75-
platforms: linux/amd64,linux/arm64
76-
7743
cherry-pick:
78-
if: contains(github.event.head_commit.message, 'hotfix:') && startsWith(github.ref, 'refs/heads/main')
44+
if: contains(github.event.head_commit.message, 'hotfix:')
7945
runs-on: ubuntu-latest
8046
needs: docker-build
8147
permissions:

.github/workflows/release.yml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,22 @@ jobs:
4040
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4141
run: npx semantic-release
4242

43-
docker-build:
44-
if: startsWith(github.ref, 'refs/tags/')
45-
runs-on: ubuntu-latest
43+
rebase-dev:
4644
needs: semantic-release
45+
runs-on: ubuntu-latest
4746
steps:
48-
- name: Checkout repository
47+
- name: Checkout dev branch
4948
uses: actions/checkout@v4
50-
51-
- name: Set up QEMU
52-
uses: docker/setup-qemu-action@v3
53-
54-
- name: Set up Docker Buildx
55-
uses: docker/setup-buildx-action@v3
56-
57-
- name: Log in to Docker Hub
58-
uses: docker/login-action@v3
59-
with:
60-
username: ${{ secrets.DOCKER_USERNAME }}
61-
password: ${{ secrets.DOCKER_PASSWORD }}
62-
63-
- name: Extract version from tag
64-
id: tag_version
65-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
66-
67-
- name: Build and push RELEASE image
68-
uses: docker/build-push-action@v2
6949
with:
70-
context: .
71-
file: ./Dockerfile
72-
push: true
73-
tags: |
74-
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
75-
${{ env.IMAGE_NAME }}:stable
76-
platforms: linux/amd64,linux/arm64
50+
ref: dev
51+
52+
- name: Set up Git
53+
run: |
54+
git config user.name "github-actions"
55+
git config user.email "[email protected]"
56+
57+
- name: Rebase dev onto main
58+
run: |
59+
git fetch origin main
60+
git rebase origin/main
61+
git push origin dev --force-with-lease

0 commit comments

Comments
 (0)