-
Notifications
You must be signed in to change notification settings - Fork 2
87 lines (84 loc) · 4 KB
/
nginx-alpine.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: nginx-alpine
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
env:
DOCKER_REPO_NAME: rookiezoe/nginx
jobs:
get_env:
runs-on: ubuntu-latest
outputs:
LATEST_TAG: ${{ steps.set_outputs.outputs.LATEST_TAG }}
NGINX_TAR: ${{ steps.set_outputs.outputs.NGINX_TAR }}
NGINX_VERSION: ${{ steps.set_outputs.outputs.NGINX_VERSION }}
NCHAN_TAR: ${{ steps.set_outputs.outputs.NCHAN_TAR }}
NCHAN_VERSION: ${{ steps.set_outputs.outputs.NCHAN_VERSION }}
steps:
- id: set_outputs
env:
DEBIAN_FRONTEND: noninteractive
name: Set outputs
run: |
sudo -E apt-get -qq update
sudo -E apt-get -qq install jq git
export QUREY_PARAMS="?page_size=2&page=1&ordering=last_updated"
export LATEST_TAG=$(echo -n $(curl -s "https://hub.docker.com/v2/repositories/${DOCKER_REPO_NAME}/tags/${QUREY_PARAMS}" | jq -r '.results | sort_by(.name) | first | .name'))
git clone https://github.com/nginx/nginx.git $GITHUB_WORKSPACE/tmp/nginx
cd $GITHUB_WORKSPACE/tmp/nginx
export NGINX_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1) | cut -d "-" -f2)
export NGINX_TAR="http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz"
git clone https://github.com/slact/nchan.git $GITHUB_WORKSPACE/tmp/nchan
cd $GITHUB_WORKSPACE/tmp/nchan
export NCHAN_LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
export NCHAN_VERSION=$(echo $NCHAN_LATEST_TAG | cut -d "v" -f2)
export NCHAN_TAR="https://github.com/slact/nchan/archive/$NCHAN_LATEST_TAG.tar.gz"
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "NGINX_TAR=$NGINX_TAR" >> $GITHUB_OUTPUT
echo "NGINX_VERSION=$NGINX_VERSION" >> $GITHUB_OUTPUT
echo "NCHAN_TAR=$NCHAN_TAR" >> $GITHUB_OUTPUT
echo "NCHAN_VERSION=$NCHAN_VERSION" >> $GITHUB_OUTPUT
publish:
if: needs.get_env.outputs.LATEST_TAG != needs.get_env.outputs.NGINX_VERSION
runs-on: ubuntu-latest
needs: get_env
steps:
- uses: actions/checkout@v3
- name: Get source codes
env:
DEBIAN_FRONTEND: noninteractive
NGINX_TAR: ${{ needs.get_env.outputs.NGINX_TAR }}
NCHAN_TAR: ${{ needs.get_env.outputs.NCHAN_TAR }}
HEADERS_MORE_TAR: https://github.com/openresty/headers-more-nginx-module/archive/master.tar.gz
run: |
wget "$NGINX_TAR" -O "$GITHUB_WORKSPACE/nginx/nginx_source.tar.gz"
wget "$NCHAN_TAR" -O "$GITHUB_WORKSPACE/nginx/nchan.tar.gz"
wget "$HEADERS_MORE_TAR" -O "$GITHUB_WORKSPACE/nginx/headers-more-nginx-module.tar.gz"
cd "$GITHUB_WORKSPACE/nginx/"
mkdir -p nginx_source nchan headers-more-nginx-module
tar -zxf nginx_source.tar.gz --strip-components 1 -C ./nginx_source
tar -xzf nchan.tar.gz --strip-components 1 -C ./nchan
tar -xzf headers-more-nginx-module.tar.gz --strip-components 1 -C ./headers-more-nginx-module
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish to DockerHub
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ env.DOCKER_REPO_NAME }}:latest,${{ env.DOCKER_REPO_NAME }}:${{ needs.get_env.outputs.NGINX_VERSION }}
context: ./nginx
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
build-args: |
NGINX_VERSION=${{ needs.get_env.outputs.NGINX_VERSION }}
NCHAN_VERSION=${{ needs.get_env.outputs.NCHAN_VERSION }}
HEADERS_MORE_VERSION=master
NGINX_SOURCE=nginx_source
NCHAN_SOURCE=nchan
HEADERS_MORE_SOURCE=headers-more-nginx-module