Add pre-commit and fix issues (#142) #1510
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: Continuous Integration | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
- 'LICENSE' | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
- 'LICENSE' | |
schedule: | |
- cron: '0 5 * * *' | |
env: | |
DOCKER_BUILDKIT: 1 | |
DOCKER_NETWORK: ${{ github.run_id }} | |
DOCKER_NETWORK_ALIAS: nginx-plus-test | |
DOCKER_NGINX_PLUS: nginx-plus-${{ github.run_id }} | |
DOCKER_NGINX_PLUS_HELPER: nginx-plus-helper-${{ github.run_id }} | |
jobs: | |
build: | |
name: Build Client | |
runs-on: ubuntu-22.04 | |
if: ${{ github.event.repository.fork == false }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Determine NGINX Plus version | |
run: echo "NGINX_PLUS_VERSION=$(cat Makefile | grep -m1 NGINX_PLUS_VERSION | cut -d "=" -f2)" >> $GITHUB_ENV | |
- name: Switch Repository (Nightly) | |
if: (github.event_name == 'schedule') | |
run: | | |
sed -i 's|pkgs.nginx.com|pkgs-test.nginx.com|g' docker/Dockerfile | |
sed -i '16d' docker/Dockerfile | |
sed -i "17i sed -i 's|pkgs|pkgs-test|g' /etc/apt/apt.conf.d/90pkgs-nginx" docker/Dockerfile | |
sed -i 's|deb https|deb [trusted=yes] https|g' docker/Dockerfile | |
sed -i 's|\${NGINX_PLUS_VERSION^^}/||g' docker/Dockerfile | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build Plus Docker Image | |
uses: docker/build-push-action@v4 | |
with: | |
file: docker/Dockerfile | |
context: 'docker' | |
tags: nginx-plus:${{ env.NGINX_PLUS_VERSION }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
load: true | |
secrets: | | |
"nginx-repo.crt=${{ secrets.NGINX_CRT }}" | |
"nginx-repo.key=${{ secrets.NGINX_KEY }}" | |
build-args: | |
NGINX_PLUS_VERSION=${{ env.NGINX_PLUS_VERSION }} | |
- name: Test Client | |
if: (github.event_name != 'schedule') | |
run: make test | |
- name: Test Client (Nightly) | |
if: (github.event_name == 'schedule') | |
run: make test | |
env: | |
NGINX_PLUS_VERSION: nightly | |
release: | |
name: Release | |
runs-on: ubuntu-22.04 | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
needs: build | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Publish Release Notes | |
uses: release-drafter/release-drafter@v5 | |
with: | |
publish: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
version: latest | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_COMMUNITY }} |