Nginx Docker Image CI for Sylius #16
This file contains 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: Nginx Docker Image CI for Sylius | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
paths: | |
- 'nginx/**' | |
schedule: | |
- cron: '0 20 * * 5' | |
concurrency: | |
group: sylius_nginx_build | |
cancel-in-progress: false | |
jobs: | |
build: | |
name: "Sylius NGINX" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: Generate UUID | |
id: generate-uuid | |
run: | | |
UUID=$(cat /proc/sys/kernel/random/uuid) | |
echo "UUID=${UUID}" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ vars.DOCKER_NGINX_REPOSITORY_NAME }} | |
tags: | | |
type=raw,value=alpine | |
type=raw,value=latest | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Cache Docker layers | |
uses: actions/[email protected] | |
with: | |
path: /tmp/.buildx-cache | |
key: "${{ runner.os }}-nginx-alpine-buildx-cache-${{ vars.CACHE_VERSION }}-${{ steps.generate-uuid.outputs.uuid }}" | |
# https://github.com/actions/cache/issues/109#issuecomment-558771281 | |
# https://github.community/t/always-save-new-cache-for-incremental-builds/172791 | |
restore-keys: "${{ runner.os }}-nginx-alpine-buildx-cache-${{ vars.CACHE_VERSION }}-" | |
- name: Docker Login | |
uses: docker/[email protected] | |
with: | |
registry: ${{ secrets.DOCKER_REGISTRY }} | |
username: ${{ secrets.DOCKER_REPOSITORY_LOGIN }} | |
password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }} | |
logout: true | |
- name: Build multiplatform | |
uses: docker/[email protected] | |
with: | |
file: ./nginx/Dockerfile | |
context: ./nginx | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }} | |
pull: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |