Skip to content

Commit

Permalink
Improve build for Nginx images
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jun 27, 2024
1 parent f722746 commit 66b6dbb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
types: [created]
workflow_dispatch:
push:
branches:
- '*'
paths:
- 'docker/hugo/**'

concurrency:
group: "docker"
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/nginx.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: build Nginx image

on:
push:
paths:
- 'docker/nginx/**'
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
Expand Down Expand Up @@ -48,12 +51,20 @@ jobs:
tags: hugomods/hugo:nginx-test
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
NGINX_VERSION=${{ steps.latest-tag.outputs.name }}
- name: Test
run: |
docker run --rm -v $PWD/site:/src hugomods/hugo:nginx-test nginx -t
- name: Check Nginx Version
run: |
DOCKER_NGINX_VERSION=$(docker run --rm -v $PWD/site:/src hugomods/hugo:nginx-test $(nginx -v 2>&1))
echo $DOCKER_NGINX_VERSION
- name: Build and push
if: ${{ steps.check.outputs.exists != true && env.BRANCH_NAME == 'main' }}
uses: docker/build-push-action@v5
with:
push: true
Expand All @@ -64,3 +75,5 @@ jobs:
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:nginx
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
NGINX_VERSION=${{ steps.latest-tag.outputs.name }}
3 changes: 2 additions & 1 deletion docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM nginx
ARG NGINX_VERSION
FROM nginx:$NGINX_VERSION
COPY conf.d/default.conf /etc/nginx/conf.d/default.conf

0 comments on commit 66b6dbb

Please sign in to comment.