-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (48 loc) · 1.82 KB
/
docker-release.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
name: Release docker image
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
releasedocker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set image name
run: echo "IMAGE_NAME="benammann/git-secrets"" >> $GITHUB_ENV
- name: Set docker username
uses: benammann/git-secrets-get-secret-action@v1
id: docker_username
with:
resource: config
name: crUser
decryptSecretName: gitsecretspublicnew
decryptSecretValue: ${{ secrets.GIT_SECRETS_PUBLIC_DEFAULT_NEW }}
- name: Set docker token
uses: benammann/git-secrets-get-secret-action@v1
id: docker_token
with:
name: crToken
decryptSecretName: gitsecretspublicnew
decryptSecretValue: ${{ secrets.GIT_SECRETS_PUBLIC_DEFAULT_NEW }}
- name: Remove ref from tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Remove v from release version
run: echo "IMAGE_TAG=${RELEASE_VERSION:1}" >> $GITHUB_ENV
- name: Docker login
run: docker login -u ${{ steps.docker_username.outputs.value }} -p ${{ steps.docker_token.outputs.value }}
- name: Docker Build
run: DATE=$(date) docker build --pull -t "$IMAGE_NAME:latest" --build-arg BUILD_VERSION=$RELEASE_VERSION --build-arg BUILD_COMMIT=$GITHUB_SHA --build-arg DATE=$DATE .
- name: Docker Push (latest tag)
run: docker push "$IMAGE_NAME:latest"
- name: Docker Tag latest as build tag
run: docker tag "$IMAGE_NAME:latest" "$IMAGE_NAME:$IMAGE_TAG"
- name: Docker Push build tag
run: docker push "$IMAGE_NAME:$IMAGE_TAG"