-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (60 loc) · 1.93 KB
/
main.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
name: CI Build
on:
push:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
steps:
- name: Code Checkout
uses: actions/checkout@v4
- name: Get Version
run: |
echo "TAGS=latest" >> $GITHUB_ENV
SUFFIX=""
VERSION=$(grep 'version:' version.yaml | cut -c 10-)$SUFFIX
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "REPO=$GITHUB_REPOSITORY" >> $GITHUB_ENV
echo "OWNER=$GITHUB_REPOSITORY_OWNER" >> $GITHUB_ENV
- name: Check if version is used
run: |
URL=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/${{ env.VERSION }}
echo "$URL"
CODE=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
if [ "$CODE" != 404 ]; then
echo "Release '$VERSION' already exists. ($CODE)"
exit 1
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ env.OWNER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Docker Build & Push
uses: docker/build-push-action@v5
with:
push: true
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386
tags: |
${{ env.REPO }}:${{ env.VERSION }}
${{ env.REPO }}:latest
- name: Creating GitHub Tag
uses: mathieudutour/[email protected]
with:
custom_tag: ${{ env.VERSION }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}