Skip to content

update wf patch

update wf patch #37

Workflow file for this run

# yamllint disable rule:truthy rule:line-length rule:document-start rule:comments-indentation
name: 'Build AdguardHome Dark'
env:
PATCH_VERSION: 'patch-1.5.4-pre'
GO_VERSION: '1.20.10'
NODE_VERSION: '16'
ADGUARDHOME_BUILD_PATH: './adguardhome'
ADGUARDHOME_DIST_PATH: './adguardhome/dist'
WGEASY_REPO_DIR: 'wg-dark'
WGEASY_BUILD_DIR: 'wg-dark-src'
BUILD_ARTIFACT: 'adguardhome-build'
ADWIREGUARD_CACHE: 'adwireguard-docker-cache'
ADWIRE_IMAGE_REPO: 'adwireguard-dark'
ADGUARD_IMAGE_REPO: 'adguardhome-dark'
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
workflow_call:
jobs:
build-latest:
name: 'Build AdGuardHome Latest'
runs-on: ubuntu-latest
outputs:
release_tag: ${{ env.release_tag }}
release_name: ${{ env.release_name }}
build_date: ${{ env.build_date }}
artifact_name: ${{ env.BUILD_ARTIFACT }}-${{ env.release_name }}
adguard_dist_path: ${{ env.adguard_dist_path }}
steps:
- name: 'Checkout'
uses: 'actions/checkout@v3'
with:
fetch-depth: 0
- name: 'Checkout AdguardHome Official Repository'
uses: 'actions/checkout@v3'
with:
repository: AdguardTeam/AdGuardHome
ref: master
path: ${{ env.ADGUARDHOME_BUILD_PATH }}
fetch-depth: 0
- name: 'Generate a Release Tag'
working-directory: ${{ env.ADGUARDHOME_BUILD_PATH }}
id: build-version
run: |
# latest_version=$( git -C "./" describe HEAD | sed 's|\(.*\)-.*|\1|' )
latest_version=$( git -C "./" describe HEAD --abbrev=0 )
echo "release_tag=${latest_version}" >> $GITHUB_ENV
echo "release_name=${latest_version}-dark" >> $GITHUB_ENV
echo "build_date=$( date -u +'%Y-%m-%dT%H:%M:%SZ' )" >> $GITHUB_ENV
echo "adguard_dist_path=${{ env.ADGUARDHOME_DIST_PATH }}/docker" >> $GITHUB_ENV
- name: 'Check AdGuardHome existing build cache'
id: check-build-cache
uses: actions/cache@v3
with:
path: ${{ env.ADGUARDHOME_DIST_PATH }}/docker
key: ${{ env.BUILD_ARTIFACT }}-${{ env.release_name }}
- name: 'Existing Build Cache Found? ${{ steps.check-build-cache.outputs.cache-hit }}'
run: |
if [ ${{ steps.check-build-cache.outputs.cache-hit }} ]
then
echo "Skipping build, existing cache found"
else
echo "No build cache found, building latest"
fi
- name: 'Clear Old AdGuardHome build cache'
if: steps.check-build-cache.outputs.cache-hit != 'true'
uses: actions/github-script@v6
with:
script: |
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
key: '${{ env.BUILD_ARTIFACT }}',
})
if (caches.data != null && caches.data.total_count > 0) {
console.log("Found %d ${{ env.BUILD_ARTIFACT }} caches", caches.data.total_count)
for (const cache of caches.data.actions_caches) {
console.log("Deleting cache=%s with cacheId=%d", cache.key, cache.id)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
} else {
console.log("no ${{ env.BUILD_ARTIFACT }} caches cleared")
}
- name: 'Fetch and Apply Dark Theme Patch'
if: steps.check-build-cache.outputs.cache-hit != 'true'
working-directory: '${{ env.ADGUARDHOME_BUILD_PATH }}'
run: |
curl "https://raw.githubusercontent.com/iganeshk/AdWireGuard-Dark/${{ env.PATCH_VERSION }}/adguardhome/adguardhome-dark-mustard-theme.patch" \
| git apply -v
- name: 'Fetch and Apply Build Scripts Patch'
if: steps.check-build-cache.outputs.cache-hit != 'true'
working-directory: '${{ env.ADGUARDHOME_BUILD_PATH }}'
run: |
curl "https://raw.githubusercontent.com/iganeshk/AdWireGuard-Dark/${{ env.PATCH_VERSION }}/adguardhome/adguardhome-build-scripts.patch" \
| git apply -v
- name: 'Set up Go'
if: steps.check-build-cache.outputs.cache-hit != 'true'
uses: 'actions/setup-go@v3'
with:
go-version: '${{ env.GO_VERSION }}'
- name: 'Set up Node'
if: steps.check-build-cache.outputs.cache-hit != 'true'
uses: 'actions/setup-node@v3'
with:
node-version: '${{ env.NODE_VERSION }}'
- name: 'Set up Go modules cache'
if: steps.check-build-cache.outputs.cache-hit != 'true'
uses: 'actions/cache@v3'
with:
path: '~/go/pkg/mod'
key: "${{ runner.os }}-go-${{ hashFiles(format('{0}/go.sum', env.ADGUARDHOME_BUILD_PATH)) }}"
restore-keys: '${{ runner.os }}-go-'
- name: 'Get npm cache directory'
if: steps.check-build-cache.outputs.cache-hit != 'true'
id: 'npm-cache'
run: |
echo "npm_cache_dir=$(npm config get cache)" >> $GITHUB_ENV
- name: 'Set up npm cache'
if: steps.check-build-cache.outputs.cache-hit != 'true'
uses: 'actions/cache@v3'
with:
path: '${{ env.npm_cache_dir }}'
key: "${{ runner.os }}-node-${{ hashFiles(format('{0}/client/package-lock.json', env.ADGUARDHOME_BUILD_PATH)) }}"
restore-keys: '${{ runner.os }}-node-'
- name: 'Build AdGuardHome Binaries'
if: steps.check-build-cache.outputs.cache-hit != 'true'
working-directory: '${{ env.ADGUARDHOME_BUILD_PATH }}'
run: |
make VERSION=${{ env.release_name }} \
BUILD_SNAP=0 SIGN=0 VERBOSE=1 OS="linux" ARCH="amd64 arm arm64" SNAP=0 \
build-release
- name: 'Prep distributables directory for docker'
if: steps.check-build-cache.outputs.cache-hit != 'true'
working-directory: '${{ env.ADGUARDHOME_DIST_PATH }}'
run: |
mkdir docker
cp "./AdGuardHome_linux_amd64/AdGuardHome/AdGuardHome" "./docker/AdGuardHome_linux_amd64_"
cp "./AdGuardHome_linux_arm64/AdGuardHome/AdGuardHome" "./docker/AdGuardHome_linux_arm64_"
cp "./AdGuardHome_linux_arm_6/AdGuardHome/AdGuardHome" "./docker/AdGuardHome_linux_arm_v6"
cp "./AdGuardHome_linux_arm_7/AdGuardHome/AdGuardHome" "./docker/AdGuardHome_linux_arm_v7"
- name: 'Cache AdGuardHome Builds'
if: steps.check-build-cache.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: ${{ env.ADGUARDHOME_DIST_PATH }}/docker
key: ${{ env.BUILD_ARTIFACT }}-${{ env.release_name }}
restore-keys: ${{ env.BUILD_ARTIFACT }}-
- name: 'Publish Releases'
if: steps.check-build-cache.outputs.cache-hit != 'true'
uses: 'ncipollo/release-action@v1'
with:
artifacts: "${{ env.ADGUARDHOME_BUILD_PATH}}/dist/*.tar.gz"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.release_tag }}
name: ${{ env.release_name }}
allowUpdates: true
build-docker-adguardhome:
name: 'Docker Build AdguardHome (Dark)'
needs: [build-latest]
runs-on: ubuntu-latest
steps:
# Login to docker and Github CR so build-docker can push images out
- name: 'Login to DockerHub'
uses: 'docker/login-action@v2'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: 'Log in to the Github Container registry'
uses: 'docker/login-action@v2'
with:
registry: 'ghcr.io'
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Set up QEMU'
uses: 'docker/setup-qemu-action@v2'
- name: 'Set up Docker Buildx'
uses: 'docker/setup-buildx-action@v2'
- name: 'Restore AdGuardHome Builds from cache'
uses: actions/cache@v3
with:
key: ${{ needs.build-latest.outputs.artifact_name }}
path: ${{ needs.build-latest.outputs.adguard_dist_path }}
- name: 'Fetch DarkAdGuardHome Dockerfile'
working-directory: ./
run: |
rm -f ./Dockerfile
curl -o ./Dockerfile "https://raw.githubusercontent.com/iganeshk/AdWireGuard-Dark/${{ env.PATCH_VERSION }}/DarkAdGuardHome.Dockerfile"
- name: 'Build & Publish AdGuardHome Dark Docker Image'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
outputs: type=image
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
build-args: |
DIST_DIR=${{ needs.build-latest.outputs.adguard_dist_path }}
labels: |
maintainer=${{ github.actor }}
org.opencontainers.image.created=${{ needs.build-latest.outputs.build_date }}
org.opencontainers.image.description=AdGuardHome Dark (${{ needs.build-latest.outputs.release_name }})
org.opencontainers.image.licenses=GPL-3.0
org.opencontainers.image.source=https://github/${{ github.repository }}
org.opencontainers.image.title=AdWireGuard
org.opencontainers.image.url=https://github/${{ github.repository }}
org.opencontainers.image.version=${{ needs.build-latest.outputs.release_name }}
tags: |
ghcr.io/${{ github.repository_owner }}/${{ env.ADGUARD_IMAGE_REPO }}:${{ needs.build-latest.outputs.release_tag }}
ghcr.io/${{ github.repository_owner }}/${{ env.ADGUARD_IMAGE_REPO }}:latest
${{ secrets.DOCKER_USERNAME }}/${{ env.ADGUARD_IMAGE_REPO }}:${{ needs.build-latest.outputs.release_tag }}
${{ secrets.DOCKER_USERNAME }}/${{ env.ADGUARD_IMAGE_REPO }}:latest
- name: 'Delete all containers from package without tags'
uses: Chizkiyahu/delete-untagged-ghcr-action@v2
with:
token: ${{ secrets.PKG_MGR_TOKEN }}
repository_owner: ${{ github.repository_owner }}
package_name: ${{ env.ADGUARD_IMAGE_REPO }}
untagged_only: true
owner_type: user
adwireguard-docker-cache:
name: 'Prep AdWireGuard Docker'
needs: [build-latest]
runs-on: ubuntu-latest
outputs:
release_tag: ${{ env.release_tag }}
release_name: ${{ env.release_name }}
build_date: ${{ env.build_date }}
artifact_name: ${{ env.BUILD_ARTIFACT }}-${{ env.release_name }}
adguard_dist_path: ${{ env.adguard_dist_path }}
steps:
- name: 'Reciprocate env vars for dependent jobs'
run: |
echo "release_tag=${{ needs.build-latest.outputs.release_tag }}" >> $GITHUB_ENV
echo "release_name=${{ needs.build-latest.outputs.release_name }}" >> $GITHUB_ENV
echo "build_date=${{ needs.build-latest.outputs.build_date }}" >> $GITHUB_ENV
echo "adguard_dist_path=${{ needs.build-latest.outputs.adguard_dist_path }}" >> $GITHUB_ENV
- name: 'Clear all old AdWireGuard caches'
uses: actions/github-script@v6
with:
script: |
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
key: '${{ env.ADWIREGUARD_CACHE }}',
})
if (caches.data != null && caches.data.total_count > 0) {
console.log("Found %d ${{ env.ADWIREGUARD_CACHE }} caches", caches.data.total_count)
for (const cache of caches.data.actions_caches) {
console.log("Deleting cache=%s with cacheId=%d", cache.key, cache.id)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
} else {
console.log("no ${{ env.ADWIREGUARD_CACHE }} caches found to be cleared")
}
- name: 'Restore AdGuardHome Builds from cache'
uses: actions/cache@v3
with:
key: ${{ needs.build-latest.outputs.artifact_name }}
path: ${{ needs.build-latest.outputs.adguard_dist_path }}
- name: 'Checkout wg-easy (official) repo into adguardhome dist directory'
uses: 'actions/checkout@v3'
with:
repository: WeeJeWel/wg-easy
ref: production
path: '${{ needs.build-latest.outputs.adguard_dist_path }}/${{ env.WGEASY_REPO_DIR }}'
fetch-depth: 0
- name: 'Apply Patches to wg-easy'
working-directory: '${{ needs.build-latest.outputs.adguard_dist_path }}/${{ env.WGEASY_REPO_DIR }}'
run: |
curl "https://raw.githubusercontent.com/iganeshk/AdWireGuard-Dark/${{ env.PATCH_VERSION }}/wg-easy/wg-easy-dark-theme.patch" | git apply -v
curl "https://raw.githubusercontent.com/iganeshk/AdWireGuard-Dark/${{ env.PATCH_VERSION }}/wg-easy/wg-easy-node18.patch" | git apply -v
- name: 'Fetch AdWireGuard Dockerfile'
working-directory: ./
run: |
rm -f ./Dockerfile
curl -o ./Dockerfile "https://raw.githubusercontent.com/iganeshk/AdWireGuard-Dark/${{ env.PATCH_VERSION }}/AdWireGuard.Dockerfile"
- name: 'Fetch Entrypoint and Prep for docker'
working-directory: '${{ needs.build-latest.outputs.adguard_dist_path }}'
run: |
# working directory - ./adguardhome/dist/docker
curl -o ./entrypoint.sh "https://raw.githubusercontent.com/iganeshk/AdWireGuard-Dark/${{ env.PATCH_VERSION }}/entrypoint.sh"
cp -r '${{ env.WGEASY_REPO_DIR }}/src/' './${{ env.WGEASY_BUILD_DIR }}'
- name: 'Temporarily Cache AdWireGuard'
uses: actions/cache@v3
with:
path: ./
key: ${{ env.ADWIREGUARD_CACHE }}
restore-keys: ${{ env.ADWIREGUARD_CACHE }}-
build-adwireguard-dockerhub:
name: 'DockerHub Build AdWireGuard'
needs: [adwireguard-docker-cache]
runs-on: ubuntu-latest
steps:
- name: 'Login to DockerHub'
uses: 'docker/login-action@v2'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: 'Set up QEMU'
uses: 'docker/setup-qemu-action@v2'
- name: 'Set up Docker Buildx'
uses: 'docker/setup-buildx-action@v2'
- name: 'Restore AdWireGuard Docker cache'
uses: actions/cache@v3
with:
key: ${{ env.ADWIREGUARD_CACHE }}
path: ./
# Build & Publish
- name: 'Dockerhub Publish - AdWireGuard'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
outputs: type=image
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
build-args: |
DIST_DIR=${{ needs.adwireguard-docker-cache.outputs.adguard_dist_path }}
WG_PATH=${{ env.WGEASY_BUILD_DIR }}
labels: |
maintainer=${{ github.actor }}
org.opencontainers.image.created=${{ needs.adwireguard-docker-cache.outputs.build_date }}
org.opencontainers.image.description=AdWireGuard Dark (AdGuard+WireGuard) (${{ needs.adwireguard-docker-cache.outputs.release_name }})
org.opencontainers.image.licenses=GPL-3.0
org.opencontainers.image.source=https://github/${{ github.repository }}
org.opencontainers.image.title=AdWireGuard Dark
org.opencontainers.image.url=https://github/${{ github.repository }}
org.opencontainers.image.version=${{ needs.adwireguard-docker-cache.outputs.release_name }}
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ env.ADWIRE_IMAGE_REPO }}:${{ needs.adwireguard-docker-cache.outputs.release_tag }}
${{ secrets.DOCKER_USERNAME }}/${{ env.ADWIRE_IMAGE_REPO }}:latest
# GithubCR workaround for manifest inssue by publishing individual architectures
build-adwireguard-ghcr:
name: 'GithubCR Build (${{ matrix.tag }})'
needs: [adwireguard-docker-cache]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: linux/arm/v6
tag: armv6
- arch: linux/arm/v7
tag: armv7
- arch: linux/arm64
tag: arm64
- arch: linux/amd64
tag: amd64
steps:
# Login to Github CR so build-docker can push images out
- name: 'Log in to the Github Container registry'
uses: 'docker/login-action@v2'
with:
registry: 'ghcr.io'
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Set up QEMU'
uses: 'docker/setup-qemu-action@v2'
- name: 'Set up Docker Buildx'
uses: 'docker/setup-buildx-action@v2'
- name: 'Restore AdWireGuard Docker cache'
uses: actions/cache@v3
with:
key: ${{ env.ADWIREGUARD_CACHE }}
path: ./
- name: 'GithubCR ${{ matrix.arch }} Publish - AdWireGuard'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
outputs: type=image
platforms: ${{ matrix.arch }}
build-args: |
DIST_DIR=${{ needs.adwireguard-docker-cache.outputs.adguard_dist_path }}
WG_PATH=${{ env.WGEASY_BUILD_DIR }}
labels: |
maintainer=${{ github.actor }}
org.opencontainers.image.created=${{ needs.adwireguard-docker-cache.outputs.build_date }}
org.opencontainers.image.description=AdWireGuard Dark (AdGuard+WireGuard) (${{ needs.adwireguard-docker-cache.outputs.release_name }})
org.opencontainers.image.licenses=GPL-3.0
org.opencontainers.image.source=https://github/${{ github.repository }}
org.opencontainers.image.title=AdWireGuard Dark
org.opencontainers.image.url=https://github/${{ github.repository }}
org.opencontainers.image.version=${{ needs.adwireguard-docker-cache.outputs.release_name }}
tags: |
ghcr.io/${{ github.repository }}:${{ matrix.tag }}
ghcr.io/${{ github.repository }}:${{ matrix.tag }}-${{ needs.adwireguard-docker-cache.outputs.release_tag }}
cleanup-untagged-containes:
name: 'Cleanup GHCR untagged images'
needs: [build-adwireguard-ghcr]
runs-on: ubuntu-latest
steps:
- name: 'Delete all images without tags'
uses: Chizkiyahu/delete-untagged-ghcr-action@v2
with:
token: ${{ secrets.PKG_MGR_TOKEN }}
repository_owner: ${{ github.repository_owner }}
repository: ${{ github.repository }}
package_name: ${{ env.ADWIRE_IMAGE_REPO }}
untagged_only: true
owner_type: user
notify:
runs-on: ubuntu-latest
needs: [build-latest]
# Secrets are not passed to workflows that are triggered by a pull request
# from a fork.
# https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
# Use always() to signal to the runner that this job must run even if the
# previous ones failed.
# 'if':
# ${{
# always() &&
# github.repository_owner == 'iganeshk' &&
# (
# github.event_name == 'push' ||
# github.event.pull_request.head.repo.full_name == github.repository
# )
# }}
if: ${{ success() }}
steps:
- name: 'Notify over Telegram'
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
${{ github.actor }} created commit:
Commit message: ${{ github.event.commits[0].message }}
Repository: ${{ github.repository }}
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
notify-on-fail:
runs-on: ubuntu-latest
needs: [build-latest]
if: ${{ failure() }}
steps:
- name: 'Notify over Telegram'
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: ${{ github.repository }}:${{ github.job }} has ${{ job.status }}