Skip to content

Commit b83eb8f

Browse files
committed
feat: rework github ci
- rework github ci workflow - introduce conventional commits - push unique image tags onto dockerhub
1 parent 5e82e2d commit b83eb8f

File tree

1 file changed

+97
-19
lines changed

1 file changed

+97
-19
lines changed

.github/workflows/docker-image.yml

Lines changed: 97 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,112 @@
1-
name: docker-ci
1+
name: CI
22

33
on:
44
push:
55
branches:
6-
- 'master'
7-
paths-ignore:
8-
- '**/README.md'
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: write
11+
packages: write
12+
pull-requests: write
913

1014
jobs:
11-
docker:
15+
16+
changelog:
17+
name: Changelog
18+
if: github.event_name != 'pull_request'
1219
runs-on: ubuntu-latest
20+
21+
outputs:
22+
skipped: ${{ steps.changelog.outputs.skipped }}
23+
tag: ${{ steps.changelog.outputs.tag }}
24+
clean_changelog: ${{ steps.changelog.outputs.clean_changelog }}
25+
version: ${{ steps.changelog.outputs.version }}
26+
1327
steps:
14-
-
15-
name: Checkout
16-
uses: actions/checkout@v2
17-
-
18-
name: Set up Docker Buildx
19-
uses: docker/setup-buildx-action@v1
20-
-
21-
name: Login to DockerHub
22-
uses: docker/login-action@v1
28+
- uses: actions/checkout@v4
29+
30+
- name: Conventional Changelog Action
31+
id: changelog
32+
uses: TriPSs/conventional-changelog-action@v5
33+
with:
34+
github-token: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Create Release
37+
uses: softprops/action-gh-release@v2
38+
if: ${{ steps.changelog.outputs.skipped == 'false' }}
39+
with:
40+
name: ${{ steps.changelog.outputs.tag }}
41+
tag_name: ${{ steps.changelog.outputs.tag }}
42+
body: ${{ steps.changelog.outputs.clean_changelog }}
43+
token: ${{ secrets.GITHUB_TOKEN }}
44+
45+
deploy:
46+
name: Deploy Image
47+
needs: changelog
48+
if: github.event_name != 'pull_request' && needs.changelog.outputs.skipped == 'false'
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- name: Get repository name
53+
id: get_repo
54+
run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2 | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
55+
56+
- name: Checkout
57+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
58+
59+
- name: Login to Dockerhub
60+
uses: docker/login-action@v1
2361
with:
2462
username: ${{ secrets.DOCKER_HUB_USERNAME }}
2563
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
26-
-
27-
name: Build and push
28-
uses: docker/build-push-action@v2
64+
65+
- name: Setup Docker Metadata
66+
uses: docker/metadata-action@dbef88086f6cef02e264edb7dbf63250c17cef6c # v5
67+
id: meta
68+
with:
69+
images: |
70+
docker.io/${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.REPO_NAME }}
71+
tags: |
72+
latest
73+
${{ needs.changelog.outputs.version }}
74+
${{ github.sha }}
75+
76+
- name: Build and Push Docker Image
77+
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5
2978
with:
3079
context: .
3180
file: Dockerfile
3281
push: true
33-
tags: l4rm4nd/xingdumper:latest
34-
platforms: linux/amd64
82+
tags: ${{ steps.meta.outputs.tags }}
83+
labels: ${{ steps.meta.outputs.labels }}
84+
85+
release:
86+
name: Release
87+
needs: changelog
88+
if: github.event_name != 'pull_request' && needs.changelog.outputs.skipped == 'false'
89+
runs-on: ubuntu-latest
90+
91+
steps:
92+
- name: Checkout
93+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
94+
95+
- name: Debug Changelog Outputs
96+
run: echo ${{ needs.changelog.outputs.tag }}
97+
98+
- name: Create Release
99+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
100+
with:
101+
token: ${{ secrets.GITHUB_TOKEN }}
102+
tag_name: ${{ needs.changelog.outputs.tag }}
103+
prerelease: false
104+
draft: false
105+
generate_release_notes: true
106+
name: ${{ needs.changelog.outputs.tag }}
107+
body: |
108+
<details>
109+
<summary>🤖 Autogenerated Conventional Changelog</summary>
110+
111+
${{ needs.changelog.outputs.clean_changelog }}
112+
</details>

0 commit comments

Comments
 (0)