generated from moul/golang-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (67 loc) · 2.22 KB
/
docker.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
name: Docker
on:
push:
branch: ['master', 'main']
tags: ['v*']
pull_request:
release:
types: [published,released]
jobs:
repoman:
runs-on: ubuntu-latest
outputs:
has-docker: ${{ steps.info.outputs.has-docker }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: moul/repoman-action@v1
id: info
multi:
needs: repoman
if: needs.repoman.outputs.has-docker == 'true'
name: "build-and-push"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.6
- name: Build the container image
uses: docker/build-push-action@v5.4.0
with:
repository: totp-cli
- name: Push to GitHub Packages
uses: docker/build-push-action@v5.4.0
if: github.event_name == 'release' || github.event_name == 'push'
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
repository: moul/totp-cli/totp-cli
tag_with_ref: true
- name: Check Docker Hub Credentials
id: check_dockerhub_credentials
if: github.event_name == 'release' || github.event_name == 'push'
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
if [ "${DOCKER_USERNAME}" == "" ]; then
echo "Missing Username"
echo "##[set-output name=missingsecrets;]$(echo yes)"
elif [ "${DOCKER_PASSWORD}" == "" ]; then
echo "Missing Password"
echo "##[set-output name=missingsecrets;]$(echo yes)"
else
echo "All secrets present"
echo "##[set-output name=missingsecrets;]$(echo no)"
fi
- name: Push to Docker Hub
if: |
(github.event_name == 'release' || github.event_name == 'push') &&
contains(steps.check_dockerhub_credentials.outputs.missingsecrets, 'no')
uses: docker/build-push-action@v5.4.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: moul/totp-cli
tag_with_ref: true