-
Notifications
You must be signed in to change notification settings - Fork 120
81 lines (72 loc) · 2.51 KB
/
publish-docker-image.yml
File metadata and controls
81 lines (72 loc) · 2.51 KB
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
name: "Publish Docker Image"
on:
push:
branches:
- release
- beta
- nightly
concurrency:
cancel-in-progress: true
group: publish-docker-image-${{ github.ref }}
permissions:
contents: read
jobs:
build_push:
name: Build and Push Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Resolve Variables
id: resolve_variables
run: |
echo "build_time=$(date --utc +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
echo "short_commit_sha=$(cut -c1-8 <<< "${{ github.sha }}")" >> $GITHUB_OUTPUT
echo "version=$(grep -oP '(?<=const val CLOUDNET = ")[^"]+' build-extensions/src/main/kotlin/eu/cloudnetservice/cloudnet/gradle/util/Versions.kt)" >> $GITHUB_OUTPUT
- name: Resolve Tags
id: resolve_tags
env:
IMAGE: "docker.io/cloudnetservice/cloudnet"
VERSION: ${{ steps.resolve_variables.outputs.version }}
SHORT_SHA: ${{ steps.resolve_variables.outputs.short_commit_sha }}
run: |
BRANCH="${{ github.ref_name }}"
if [[ "$BRANCH" == "nightly" ]]; then
TAGS="${IMAGE}:nightly-latest,${IMAGE}:nightly-${SHORT_SHA}"
else
TAGS="${IMAGE}:${BRANCH}-latest,${IMAGE}:${VERSION}"
fi
echo "tags=$TAGS" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Publish to Docker Hub
uses: docker/build-push-action@v6
with:
push: true
context: "."
file: "Dockerfile"
sbom: true
provenance: true
platforms: |
linux/amd64
linux/arm64
tags: ${{ steps.resolve_tags.outputs.tags }}
build-args: |
REVISION=${{ github.sha }}
BRANCH=${{ github.ref_name }}
VERSION=${{ steps.resolve_variables.outputs.version }}
CREATED=${{ steps.resolve_variables.outputs.build_time }}
- name: Update Dockerhub Description
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: "cloudnetservice/cloudnet"
enable-url-completion: true