Merge pull request #442 from Quetzacoalt91/build-then-push #140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Publish images | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
list_base_images: | |
runs-on: ubuntu-latest | |
outputs: | |
versions: ${{ steps.set-versions.outputs.versions }} | |
base_has_changed: ${{ steps.changes.outputs.base }} | |
steps: | |
- uses: actions/checkout@v2 | |
- id: set-versions | |
run: echo "versions=$(ls base/images/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT | |
- uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
base: | |
- 'base/**' | |
list_prestashop_images: | |
runs-on: ubuntu-latest | |
outputs: | |
versions: ${{ steps.set-versions.outputs.versions }} | |
steps: | |
# Fetch versions to work for images | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- id: set-versions | |
run: echo "versions=$(./get_json_versions.py)" >> $GITHUB_OUTPUT | |
publish_base: | |
runs-on: ubuntu-latest | |
needs: list_base_images | |
strategy: | |
matrix: | |
version: ${{ fromJson(needs.list_base_images.outputs.versions) }} | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Enable multi-platform builds | |
uses: docker/setup-buildx-action@v3 | |
with: | |
name: container | |
version: latest | |
- uses: actions/checkout@v2 | |
- name: Base Images > Generate Tags | |
run: ./generate_tags.sh | |
working-directory: base | |
- name: Base Images > Docker Build Tags | |
run: DOCKER_REPOSITORY=${{ vars.DOCKER_BASE_REPOSITORY}} ./docker_tags.sh --version ${{ matrix.version }} | |
if: ${{ github.event_name == 'pull_request' }} | |
working-directory: base | |
- name: Base Images > Docker Build & Force Push | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.list_base_images.outputs.base_has_changed == 'true' }} | |
run: DOCKER_REPOSITORY=${{ vars.DOCKER_BASE_REPOSITORY}} ./docker_tags.sh -p -f --version ${{ matrix.version }} | |
working-directory: base | |
publish_prestashop: | |
runs-on: ubuntu-latest | |
needs: | |
- list_prestashop_images | |
- publish_base | |
- list_base_images | |
strategy: | |
max-parallel: 2 | |
fail-fast: false | |
matrix: | |
ps-version: ${{ fromJson(needs.list_prestashop_images.outputs.versions) }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
image_has_changed: | |
- 'images/${{ matrix.ps-version }}/**' | |
- name: Set up QEMU | |
if: ${{ steps.filter.outputs.image_has_changed == 'true' }} | |
uses: docker/setup-qemu-action@v3 | |
- name: Enable multi-platform builds | |
if: ${{ steps.filter.outputs.image_has_changed == 'true' }} | |
uses: docker/setup-buildx-action@v3 | |
with: | |
name: container | |
version: latest | |
- name: Set up Python | |
if: ${{ steps.filter.outputs.image_has_changed == 'true' }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
if: ${{ steps.filter.outputs.image_has_changed == 'true' }} | |
run: pip install -r requirements.txt | |
- name: Build Docker images | |
if: ${{ steps.filter.outputs.image_has_changed == 'true' }} | |
run: DOCKER_REPOSITORY=${{ vars.DOCKER_REPOSITORY}} ./prestashop_docker.py --quiet tag build ${{ matrix.ps-version }} --force | |
- name: Login to Docker Hub | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && (needs.list_base_images.outputs.base_has_changed == 'true' || steps.filter.outputs.image_has_changed == 'true') }} | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build by using cache and push Docker images | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && (needs.list_base_images.outputs.base_has_changed == 'true' || steps.filter.outputs.image_has_changed == 'true') }} | |
run: DOCKER_REPOSITORY=${{ vars.DOCKER_REPOSITORY}} ./prestashop_docker.py --quiet tag push ${{ matrix.ps-version }} --force | |