Skip to content

Commit

Permalink
Add a workflow to publish the Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Jul 31, 2022
1 parent e1e6b58 commit 86fa5fc
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish Docker image

permissions:
contents: read
packages: write

on:
push:
tags:
- 'v*'

env:
IMAGE_TAG: docker.io/botsudo/docker-openldap:latest

jobs:
push_to_registry:
environment:
name: Docker Hub
url: https://hub.docker.com/r/botsudo/docker-openldap
name: Push Docker image to DockerHub and GitHub Container Registry
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }}
password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }}

- name: Build image
run: make docker-build
- name: Test image
run: make test

#- name: Sign and push docker image
# uses: sudo-bot/action-docker-sign@latest
# with:
# image-ref: "docker.io/botsudo/action-docker-compose:latest"
# private-key-id: "${{ secrets.DOCKER_PRIVATE_KEY_ID }}"
# private-key: ${{ secrets.DOCKER_PRIVATE_KEY }}
# private-key-passphrase: ${{ secrets.DOCKER_PRIVATE_KEY_PASSPHRASE }}

- name: Push to GHCR
run: make docker-push
- name: Tag for GHCR
run: make docker-tag-ghcr
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to GitHub Container Registry
run: make docker-push-ghcr
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
IMAGE_TAG ?= action-docker-compose
IMAGE_TAG_GHCR ?= ghcr.io/sudo-bot/docker-openldap/docker-openldap:latest

.PHONY: update-tags docker-build

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

docker-tag-ghcr:
docker tag $(IMAGE_TAG) $(IMAGE_TAG_GHCR)

docker-push:
docker push $(IMAGE_TAG)

docker-push-ghcr:
docker push $(IMAGE_TAG_GHCR)

update-tags:
git checkout main
git tag -s -f -a -m "latest series" latest
Expand Down

0 comments on commit 86fa5fc

Please sign in to comment.