-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (92 loc) · 3.1 KB
/
worker84-docker-public.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Publish Worker 8.4 image to Docker Hub
on:
push:
branches:
- main
permissions:
contents: write
env:
IMAGE_NAME: dev-worker84
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_ID: ${{ secrets.DOCKERHUB_ID }}
jobs:
push_to_registry:
if: github.event_name != 'pull_request'
name: Build and push Worker84 image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into Docker Hub
uses: docker/login-action@v3
with:
registry: https://index.docker.io/v1/
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_PASSWORD }}
- name: Get latest version tag
id: get_version
run: |
git fetch --tags
# get the latest tag with regex pattern have vworker84 prefix
latest_tag=$(git tag -l | grep -E '^vworker84' | sort -V | tail -n 1)
echo "Latest tag: $latest_tag"
echo "version=$latest_tag" >> $GITHUB_OUTPUT
- name: Increment version number
id: inc_version
run: |
version=${{ steps.get_version.outputs.version }}
version=${version#"v"}
if [ -z "$version" ]; then
major=0
minor=0
patch=0
else
IFS='.' read -r -a parts <<< "$version"
major=${parts[0]:-0}
minor=${parts[1]:-0}
patch=${parts[2]:-0}
fi
patch=$((patch+1))
if [ "$patch" -ge 100 ]; then
patch=0
minor=$((minor+1))
fi
if [ "$minor" -ge 10]; then
minor=0
major=$((major+1))
fi
new_version="v$major.$minor.$patch"
echo "New version: $new_version"
echo "new_version=$new_version" >> $GITHUB_OUTPUT
- name: Set new version tag
run: |
git tag ${{ steps.inc_version.outputs.new_version }}
git push origin ${{ steps.inc_version.outputs.new_version }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKERHUB_ID }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=${{ steps.inc_version.outputs.new_version }}
- name: Build and push Worker84 image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: worker84
push: true
tags: |
${{ env.DOCKERHUB_ID }}/${{ env.IMAGE_NAME }}:latest
${{ env.DOCKERHUB_ID }}/${{ env.IMAGE_NAME }}:${{ steps.inc_version.outputs.new_version }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PHP_VERSION=8.4
USER_ID=1000
GROUP_ID=1000