diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c63abfbb..82f832db 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -37,6 +37,16 @@ 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: + filters: | + base: + - 'base/**' + - name: Set up Python 3.8 uses: actions/setup-python@v2 with: @@ -52,10 +62,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}')