forked from eea/eea.docker.rsync
-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (70 loc) · 2.56 KB
/
master.yml
File metadata and controls
77 lines (70 loc) · 2.56 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
name: CI
on:
push:
branches:
- master
tags:
- "*"
- "**"
- v*
schedule:
- cron: "53 2 * * 2"
workflow_dispatch:
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
token: ${{ secrets.OWNER_TOKEN }}
fetch-depth: 0 # Required to get tags
- name: Set up QEMU
uses: docker/setup-qemu-action@v4.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.0.0
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: mtand
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Get Previous tag"
id: current_version
uses: "WyriHaximus/github-action-get-previous-tag@v2.0.0"
with:
fallback: 1.0.0 # Optional fallback tag to use when no tag can be found
- name: get docker tag
id: git
run: |
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "DOCKER_TAG=mtand/rsync:latest,mtand/rsync:${{ steps.current_version.outputs.tag }},mtand/rsync:${{ steps.current_version.outputs.tag }}.$(date +%y%j)" >> $GITHUB_OUTPUT
elif [ "${GITHUB_REF#refs/heads/}" == "master" ]; then
echo "DOCKER_TAG=mtand/rsync:latest" >> $GITHUB_OUTPUT
else
echo "DOCKER_TAG=mtand/rsync:${GITHUB_REF#refs/tags/},mtand/rsync:${GITHUB_REF#refs/tags/}.$(date +%y%j)" >> $GITHUB_OUTPUT
fi
- name: Result
run: |
echo "Prev tag: ${{ steps.current_version.outputs.tag }}"
echo "Docker tag: ${{ steps.git.outputs.DOCKER_TAG }}"
echo "${{ github.event_name }}"
- name: Build and push
id: docker_build
uses: docker/build-push-action@v7.2.0
with:
push: true
provenance: false
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm/v6,linux/arm64,linux/arm/v7
tags: ${{ steps.git.outputs.DOCKER_TAG }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Extract tag
run: |
set -e -x
TAG=$(grep -Po 'alpine:\K(.*)' Dockerfile)
git tag $TAG || echo "Existing tag"
git push origin $TAG || echo "tag exists"