Skip to content

Commit

Permalink
Merge pull request #83 from LedgerHQ/ci/deactivate_push
Browse files Browse the repository at this point in the history
No more automatic Docker image push
  • Loading branch information
lpascal-ledger authored Sep 1, 2023
2 parents d5bfe2e + 66d05c4 commit 52f8fb4
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ name: Publish Docker images

on:
workflow_dispatch:
push:
branches:
- master
pull_request:

env:
Expand All @@ -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."
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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' }}

0 comments on commit 52f8fb4

Please sign in to comment.