Skip to content

Commit 86fa5fc

Browse files
committed
Add a workflow to publish the Docker image
1 parent e1e6b58 commit 86fa5fc

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

.github/workflows/publish.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish Docker image
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
7+
on:
8+
push:
9+
tags:
10+
- 'v*'
11+
12+
env:
13+
IMAGE_TAG: docker.io/botsudo/docker-openldap:latest
14+
15+
jobs:
16+
push_to_registry:
17+
environment:
18+
name: Docker Hub
19+
url: https://hub.docker.com/r/botsudo/docker-openldap
20+
name: Push Docker image to DockerHub and GitHub Container Registry
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Check out the repository
24+
uses: actions/checkout@v3
25+
- name: Login to DockerHub
26+
uses: docker/login-action@v1
27+
with:
28+
registry: docker.io
29+
username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }}
30+
password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }}
31+
32+
- name: Build image
33+
run: make docker-build
34+
- name: Test image
35+
run: make test
36+
37+
#- name: Sign and push docker image
38+
# uses: sudo-bot/action-docker-sign@latest
39+
# with:
40+
# image-ref: "docker.io/botsudo/action-docker-compose:latest"
41+
# private-key-id: "${{ secrets.DOCKER_PRIVATE_KEY_ID }}"
42+
# private-key: ${{ secrets.DOCKER_PRIVATE_KEY }}
43+
# private-key-passphrase: ${{ secrets.DOCKER_PRIVATE_KEY_PASSPHRASE }}
44+
45+
- name: Push to GHCR
46+
run: make docker-push
47+
- name: Tag for GHCR
48+
run: make docker-tag-ghcr
49+
- name: Login to GitHub Container Registry
50+
uses: docker/login-action@v2
51+
with:
52+
registry: ghcr.io
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
- name: Push to GitHub Container Registry
56+
run: make docker-push-ghcr

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1+
IMAGE_TAG ?= action-docker-compose
2+
IMAGE_TAG_GHCR ?= ghcr.io/sudo-bot/docker-openldap/docker-openldap:latest
3+
14
.PHONY: update-tags docker-build
25

36
docker-build:
47
docker build ./docker \
8+
--tag $(IMAGE_TAG) \
59
--build-arg VCS_REF=`git rev-parse HEAD` \
610
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
711

12+
docker-tag-ghcr:
13+
docker tag $(IMAGE_TAG) $(IMAGE_TAG_GHCR)
14+
15+
docker-push:
16+
docker push $(IMAGE_TAG)
17+
18+
docker-push-ghcr:
19+
docker push $(IMAGE_TAG_GHCR)
20+
821
update-tags:
922
git checkout main
1023
git tag -s -f -a -m "latest series" latest

0 commit comments

Comments
 (0)