verbose curl #8
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: CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- "*.md" | |
- "LICENSE" | |
env: | |
IMAGE_NAME: ghcr.io/${{ github.repository }} | |
jobs: | |
fetch: | |
name: Fetch latest NextDNS CLI release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
with: | |
fetch-depth: 0 | |
- name: Fetch information from GitHub API | |
id: release | |
run: | | |
NEXTDNS_TAG=$(curl -svL https://api.github.com/repos/nextdns/nextdns/releases/latest | jq -r ".tag_name") | |
RELEASE_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) || true) | |
RELEASE_NUM=$(echo "$RELEASE_TAG" | rev | cut -d "-" -f1 | rev) | |
if [[ -z "$RELEASE_NUM" || "$RELEASE_NUM" = "$RELEASE_TAG" ]]; then | |
RELEASE_NUM="-1" | |
fi | |
if [[ "$(echo "$RELEASE_TAG" | rev | cut -d "-" -f2- | rev)" == "$NEXTDNS_TAG" ]]; then | |
exit 1 | |
#RELEASE_NUM=$(echo "$RELEASE_NUM+1" | bc) | |
else | |
RELEASE_NUM="0" | |
fi | |
echo "::set-output name=nextdns_tag::$NEXTDNS_TAG" | |
echo "::set-output name=release_tag::$RELEASE_TAG" | |
echo "::set-output name=nextdns_ver::$(echo "$NEXTDNS_TAG" | sed "s/^v//")" | |
echo "::set-output name=docker_ver::$(echo "$RELEASE_TAG" | sed "s/^v//" | rev | cut -d "-" -f2- | rev)" | |
echo "::set-output name=release_new::$NEXTDNS_TAG-$RELEASE_NUM" | |
- name: Repo keep-alive | |
uses: gautamkrishnar/keepalive-workflow@master | |
continue-on-error: true | |
with: | |
commit_message: repo keepalive [ci skip] | |
committer_username: JeDa | |
committer_email: "bot@jeda.im" | |
outputs: | |
nextdns_tag: ${{ steps.release.outputs.nextdns_tag }} | |
release_tag: ${{ steps.release.outputs.release_tag }} | |
nextdns_ver: ${{ steps.release.outputs.nextdns_ver }} | |
docker_ver: ${{ steps.release.outputs.docker_ver }} | |
release_new: ${{ steps.release.outputs.release_new }} | |
build: | |
name: Build Docker images | |
runs-on: ubuntu-latest | |
needs: fetch | |
if: needs.fetch.outputs.docker_ver != needs.fetch.outputs.nextdns_ver || github.ref == 'refs/heads/master' | |
env: | |
# This should be all the platforms both NextDNS and Alpine for Docker support in common. | |
ARCH_LIST: linux/amd64,linux/arm64, | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3.0.0 | |
with: | |
platforms: ${{ env.ARCH_LIST }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3.1.0 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and export Docker image | |
uses: docker/build-push-action@v5.1.0 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
build-args: | | |
NEXTDNS_VERSION=${{ needs.fetch.outputs.nextdns_ver }} | |
tags: ${{ env.IMAGE_NAME }}:latest | |
- name: Test Image | |
run: | | |
docker run --rm ${{ env.IMAGE_NAME }}:latest | |
- name: Push Docker image | |
uses: docker/build-push-action@v5.1.0 | |
with: | |
platforms: ${{ env.ARCH_LIST }} | |
push: true | |
builder: ${{ steps.buildx.outputs.name }} | |
build-args: | | |
NEXTDNS_VERSION=${{ needs.fetch.outputs.nextdns_ver }} | |
tags: ${{ env.IMAGE_NAME }}:latest,${{ env.IMAGE_NAME }}:${{ needs.fetch.outputs.nextdns_ver }} | |
tag: | |
name: Publish version tag | |
runs-on: ubuntu-latest | |
needs: [fetch, build] | |
steps: | |
- name: Publish GitHub release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NEXTDNS_TAG: ${{ needs.fetch.outputs.nextdns_tag }} | |
NEXTDNS_VER: ${{ needs.fetch.outputs.nextdns_ver }} | |
RELEASE_NEW: ${{ needs.fetch.outputs.release_new }} | |
with: | |
tag_name: ${{ env.RELEASE_NEW }} | |
release_name: ${{ env.RELEASE_NEW }} | |
body: | | |
This is an automated deployment of [NextDNS CLI ${{ env.NEXTDNS_TAG }}](https://github.com/nextdns/nextdns/releases/${{ env.NEXTDNS_TAG }}). | |
You should be able to fetch this image using Docker/podman. | |
```sh | |
docker pull ${{ env.IMAGE_NAME }}:latest # always up-to-date | |
docker pull ${{ env.IMAGE_NAME }}:${{ env.NEXTDNS_VER }} # stick to this NextDNS release | |
``` |