diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..93c41b4 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 diff --git a/Makefile b/Makefile index ebd6ff1..46548fb 100644 --- a/Makefile +++ b/Makefile @@ -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