Skip to content

Commit

Permalink
feat: push commit to ghcr, keep clean dockerhub release
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Jul 11, 2024
1 parent 1333248 commit 74698bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- '1.*'
tags:
- '*'

Expand All @@ -27,9 +28,9 @@ jobs:
- name: "Build gateway"
run: make install test

- name: "Resolve docker image tag"
- name: Getting image tag
id: version
run: echo ::set-output name=VERSION::$(./mvnw -f gateway/ help:evaluate -q -DforceStdout -Dexpression=imageTag)
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)

- name: "Build docker image"
if: github.repository == 'georchestra/georchestra-gateway'
Expand All @@ -46,6 +47,11 @@ jobs:
if: github.ref == 'refs/heads/main' && github.repository == 'georchestra/georchestra-gateway'
run: docker push georchestra/gateway:latest

- name: "Pushing release branch to docker.io"
if: contains(github.ref, 'refs/heads/1.') && github.repository == 'georchestra/georchestra-gateway' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request'
run: |
docker push georchestra/gateway:${{ steps.version.outputs.VERSION }}
- name: "Push tagged image to docker.io"
if: github.ref_type == 'tag' && github.ref != 'refs/heads/main' && github.repository == 'georchestra/georchestra-gateway'
run: docker push georchestra/gateway:${{ steps.version.outputs.VERSION }}
Expand All @@ -60,11 +66,19 @@ jobs:
readme-filepath: ./DOCKER_HUB.md
short-description: 'Gateway module for the geOrchestra SDI'

- name: "Push image attached to commit id to docker.io"
- name: Login to GitHub Container Registry
if: github.ref == 'refs/heads/main' && github.repository == 'georchestra/georchestra-gateway'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Push image attached to commit id to ghcr.io"
if: github.ref == 'refs/heads/main' && github.repository == 'georchestra/georchestra-gateway'
run: |
docker tag georchestra/gateway:latest georchestra/gateway:commit-${{ github.sha }}
docker push georchestra/gateway:commit-${{ github.sha }}
docker tag georchestra/gateway:latest ghcr.io/georchestra/georchestra-gateway/gateway:commit-${{ github.sha }}
docker push ghcr.io/georchestra/georchestra-gateway/gateway:commit-${{ github.sha }}
- name: "Remove SNAPSHOT jars from repository"
run: |
Expand Down
2 changes: 1 addition & 1 deletion DOCKER_HUB.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Featured tags

- `latest`, `1.0.0`
- `latest`, `1.0.x`, `1.0.0`

# Quick reference

Expand Down

0 comments on commit 74698bf

Please sign in to comment.