From 0d9e7ace9e2bc8f830a7b255fce5c2f279f5acbd Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 25 Jan 2024 13:23:43 +0100 Subject: [PATCH 1/2] Force publish if there are modifications in base directory --- .github/workflows/publish.yml | 14 +++++++++++++- base/config_files/ps-extractor.sh | 1 + base/docker_tags.sh | 9 +++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c63abfbb..da75e9bb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -37,6 +37,13 @@ jobs: - uses: actions/checkout@v2 + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + base: + - 'base/**' + - name: Set up Python 3.8 uses: actions/setup-python@v2 with: @@ -52,10 +59,15 @@ jobs: working-directory: base - name: Base Images > Docker Build & Push - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.changes.outputs.base != 'true' }} run: ./docker_tags.sh -p working-directory: base + - name: Base Images > Docker Build & Push + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.changes.outputs.base == 'true' }} + run: ./docker_tags.sh -p -f + working-directory: base + - name: Install dependencies run: pip install -r requirements.txt diff --git a/base/config_files/ps-extractor.sh b/base/config_files/ps-extractor.sh index 2c232fcb..d0fbc45f 100644 --- a/base/config_files/ps-extractor.sh +++ b/base/config_files/ps-extractor.sh @@ -11,6 +11,7 @@ if [[ -n "$folder" ]]; then fi chown www-data:www-data -R $folder/prestashop/ + # Copy all files (included .env files) cp -n -R -T -p $folder/prestashop/ /var/www/html else echo "Missing folder to move" diff --git a/base/docker_tags.sh b/base/docker_tags.sh index 821f5fa6..152a7f83 100755 --- a/base/docker_tags.sh +++ b/base/docker_tags.sh @@ -8,11 +8,15 @@ else PS_VERSIONS_FILE="$1"; fi -while getopts ":p" option; do +FORCE=false +while getopts ":fp" option; do case $option in p) PUSH=true ;; + f) + FORCE=true + ;; esac done @@ -22,8 +26,9 @@ docker_tag_exists() { docker_image() { - if docker_tag_exists prestashop/base ${version}; then + if ! $FORCE && docker_tag_exists prestashop/base ${version}; then echo "Docker Image already pushed : prestashop/base:$version" + return else echo "Docker build & tag : prestashop/base:$version" id=$(echo $(docker build --quiet=true images/${version} 2>/dev/null) | awk '{print $NF}') From e7746e6291dfa6eb2569ed8519eb6ee6404846ca Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 25 Jan 2024 14:25:36 +0100 Subject: [PATCH 2/2] Added comment --- .github/workflows/publish.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index da75e9bb..82f832db 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -37,6 +37,9 @@ jobs: - uses: actions/checkout@v2 + ## Check if there are modifications in the base/ directory + ## and store it in the variable `steps.changes.outputs.base` + ## The variable is built like: steps.{#id}.outputs.{#filter} - uses: dorny/paths-filter@v2 id: changes with: