diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bcf0723..355b2ad 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,9 +4,6 @@ name: Publish Docker images on: workflow_dispatch: - push: - branches: - - master pull_request: env: @@ -22,35 +19,35 @@ jobs: steps: - name: Clone uses: actions/checkout@v3 - + - name: Get current version id: get-current-version run: | echo "current_version=$(grep -Po '(?<=## \[)(\d\.)+[^\]]' CHANGELOG.md | head -n 1)" >> "$GITHUB_OUTPUT" - + - name: Login to registry uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Check already existing image run: | - GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64) - + GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64) + # Get tags of all images from GHCR TAGS_FULL=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}/tags/list) TAGS_LITE=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}-lite/tags/list) TAGS_LEGACY=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}-legacy/tags/list) TAGS_DEV_TOOLS=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/ledger-app-dev-tools/tags/list) - + # Concatenate all tags from json fields in one string without brackets ALL_TAGS=$(echo $TAGS_FULL $TAGS_LITE $TAGS_LEGACY $TAGS_DEV_TOOLS | jq -s '.[0].tags + .[1].tags + .[2].tags + .[3].tags' | tr -d '[]') - + # Get the tag to find TAG_TO_FIND=${{ steps.get-current-version.outputs.current_version }} - + # Check if the tag to find is already present in the list of tags if [[ "$ALL_TAGS" == *"$TAG_TO_FIND"* ]]; then echo "An image tagged with the latest changelog version already exists on GHCR. Please update the changelog." @@ -61,7 +58,7 @@ jobs: outputs: current_version: ${{ steps.get-current-version.outputs.current_version }} - + mods_list: name: Get modified files runs-on: ubuntu-latest @@ -119,7 +116,7 @@ jobs: platforms: ${{ env.BUILD_PLATFORMS }} tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ needs.check_changelog.outputs.current_version }} labels: ${{ steps.meta.outputs.labels }} - push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch' }} + push: ${{ github.event_name == 'workflow_dispatch' }} builder_legacy: name: App Builder Legacy @@ -156,7 +153,7 @@ jobs: file: legacy/Dockerfile tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ needs.check_changelog.outputs.current_version }} labels: ${{ steps.meta.outputs.labels }} - push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch' }} + push: ${{ github.event_name == 'workflow_dispatch' }} builder: name: App Builder @@ -200,7 +197,7 @@ jobs: platforms: ${{ env.BUILD_PLATFORMS }} tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ needs.check_changelog.outputs.current_version }} labels: ${{ steps.meta.outputs.labels }} - push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch' }} + push: ${{ github.event_name == 'workflow_dispatch' }} dev_tools: name: App Developer Tools @@ -244,4 +241,4 @@ jobs: platforms: ${{ env.BUILD_PLATFORMS }} tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ needs.check_changelog.outputs.current_version }} labels: ${{ steps.meta.outputs.labels }} - push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch' }} + push: ${{ github.event_name == 'workflow_dispatch' }}