-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (76 loc) · 2.63 KB
/
docker.yaml
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
82
83
84
85
86
87
88
name: docker
on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
jobs:
docker:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check containr registry enabled
run: |
GHCR_ENABLED="true"
echo "GHCR_ENABLED=${GHCR_ENABLED}"
echo "GHCR_ENABLED=${GHCR_ENABLED}" >> $GITHUB_ENV
DOCKERHUB_ENABLED="false"
if [ "${{ secrets.DOCKERHUB_USERNAME }}" != "" -a "${{ secrets.DOCKERHUB_TOKEN }}" != "" ]; then
DOCKERHUB_ENABLED="true"
if [ -e "README.md" ]; then
DOCKERHUB_README="true"
fi
fi
echo "DOCKERHUB_ENABLED=${DOCKERHUB_ENABLED}"
echo "DOCKERHUB_ENABLED=${DOCKERHUB_ENABLED}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
if: env.DOCKERHUB_ENABLED == 'true'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: env.GHCR_ENABLED == 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
name=ncsa/puppet-enc,enable=${{ env.DOCKERHUB_ENABLED }}
name=ghcr.io/${{ github.repository_owner }}/puppet-enc,enable=${{ env.GHCR_ENABLED }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
if: github.ref == 'refs/heads/main' && env.DOCKERHUB_README == 'true'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ncsa/puppet-enc
short-description: ${{ github.event.repository.description }}