build Nginx image #25
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: build Nginx image | |
on: | |
schedule: | |
- cron: '0 0 * * 0' | |
workflow_dispatch: | |
env: | |
PLATFORMS: linux/amd64,linux/arm64 | |
IMAGE_OWNER: hugomods | |
IMAGE_NAME: hugo | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: ${{ env.PLATFORMS }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
platforms: ${{ env.PLATFORMS }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ env.IMAGE_OWNER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ env.IMAGE_OWNER }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v4 | |
with: | |
load: true | |
context: docker/nginx | |
tags: ${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:nginx-test | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Test | |
run: | | |
docker run --rm -v $PWD/site:/src ${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:nginx-test nginx -t | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
context: docker/nginx | |
platforms: ${{ env.PLATFORMS }} | |
tags: | | |
${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:nginx | |
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:nginx | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |