88 workflow_dispatch :
99 pull_request :
1010 types : [opened, synchronize, reopened, edited]
11+ release :
12+ types : [published]
1113
1214jobs :
1315 build-and-push :
3234 username : ${{ github.actor }}
3335 password : ${{ secrets.GITHUB_TOKEN }}
3436
37+ - name : Set Docker image tags and build args
38+ id : docker_tags
39+ run : |
40+ TAGS="ghcr.io/obeone/crawler-to-md:latest\ndocker.io/obeoneorg/crawler-to-md:latest"
41+ if [ "${{ github.event_name }}" = "release" ] && [ -n "${{ github.event.release.tag_name }}" ]; then
42+ TAGS="$TAGS\nghcr.io/obeone/crawler-to-md:${{ github.event.release.tag_name }}\ndocker.io/obeoneorg/crawler-to-md:${{ github.event.release.tag_name }}"
43+ fi
44+
45+ APP_VERSION=0.0.0
46+ if [ "${{ github.event_name }}" = "release" ] && [ -n "${{ github.event.release.tag_name }}" ]; then
47+ APP_VERSION=${{ github.event.release.tag_name }}
48+ fi
49+
50+ echo "tags<<EOF" >> $GITHUB_OUTPUT
51+ echo -e "$TAGS" >> $GITHUB_OUTPUT
52+ echo "EOF" >> $GITHUB_OUTPUT
53+
54+ echo "build_args<<EOF" >> $GITHUB_OUTPUT
55+ echo -e "APP_VERSION=$APP_VERSION" >> $GITHUB_OUTPUT
56+ echo "EOF" >> $GITHUB_OUTPUT
57+
58+
3559 - name : Log in to Docker Hub
3660 if : (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
3761 uses : docker/login-action@v2
@@ -46,12 +70,11 @@ jobs:
4670 with :
4771 context : .
4872 file : ./Dockerfile
49- push : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
73+ push : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch') || github.event_name == 'release ' }}
5074 cache-from : type=gha
5175 cache-to : type=gha,mode=max
52- tags : |
53- ghcr.io/obeone/crawler-to-md:latest
54- docker.io/obeoneorg/crawler-to-md:latest
76+ tags : ${{ steps.docker_tags.outputs.tags }}
77+ build-args : ${{ steps.docker_tags.outputs.build_args }}
5578 platforms : linux/amd64,linux/arm64
5679
5780 - name : Set up cosign
6790 COSIGN_EXPERIMENTAL : true
6891 DIGEST : ${{ steps.docker_build.outputs.digest }}
6992
70- - name : Updage Docker Hub description
93+ - name : Update Docker Hub description
7194 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
7295 uses : peter-evans/dockerhub-description@v4
7396 with :
0 commit comments