FTL/.github/workflows/build.yml

134 lines
4.0 KiB
YAML

name: Build, Test, Deploy
on:
push:
branches:
- '**'
- '!dependabot/**'
pull_request:
branches-ignore:
- 'dependabot/**'
release:
types: [published]
jobs:
build:
if: |
github.event_name == 'push'
|| github.event_name == 'release'
|| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
outputs:
GIT_TAG: ${{ steps.variables.outputs.GIT_TAG }}
GIT_BRANCH: ${{ steps.variables.outputs.GIT_BRANCH }}
OUTPUT_DIR: ${{ steps.variables.outputs.OUTPUT_DIR }}
runs-on: ubuntu-latest
container: ghcr.io/pi-hole/ftl-build:v1.18-${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
bin_name: pihole-FTL-linux-x86_64
- arch: x86_64-musl
bin_name: pihole-FTL-musl-linux-x86_64
- arch: x86_32
bin_name: pihole-FTL-linux-x86_32
- arch: armv4t
bin_name: pihole-FTL-armv4-linux-gnueabi
- arch: armv5te
bin_name: pihole-FTL-armv5-linux-gnueabi
- arch: armv6hf
bin_name: pihole-FTL-armv6-linux-gnueabihf
- arch: armv7hf
bin_name: pihole-FTL-armv7-linux-gnueabihf
- arch: armv8a
bin_name: pihole-FTL-armv8-linux-gnueabihf
- arch: aarch64
bin_name: pihole-FTL-aarch64-linux-gnu
env:
CI_ARCH: ${{ matrix.arch }}
steps:
-
name: Checkout code
uses: actions/checkout@v3
-
name: Calculate required build variables
id: variables
run: |
GIT_TAG=${{ github.event.release.tag_name }}
# If GIT_TAG is set then GIT BRANCH should be "master", else set it from GITHUB_REF
GIT_BRANCH=$([ -n "${GIT_TAG}" ] && echo "master" || echo "${GITHUB_REF#refs/*/}")
echo ::set-output name=GIT_BRANCH::${GIT_BRANCH}
echo ::set-output name=GIT_TAG::${GIT_TAG}
echo ::set-output name=OUTPUT_DIR::${GIT_TAG:-${GIT_BRANCH}}
-
name: "Fix ownership of repository"
run: chown -R root .
-
name: "Build"
env:
GIT_BRANCH: ${{ steps.variables.outputs.GIT_BRANCH }}
GIT_TAG: ${{ steps.variables.outputs.GIT_TAG }}
run: |
bash build.sh "-DSTATIC=${STATIC}"
-
name: "Binary checks"
run: |
bash test/arch_test.sh
-
name: "Test x86_32/64 binaries"
if: matrix.arch == 'x86_64' || matrix.arch == 'x86_64-musl' || matrix.arch == 'x86_32'
run: |
bash test/run.sh
-
name: "Generate checksum file"
run: |
mv pihole-FTL "${{ matrix.bin_name }}"
sha1sum pihole-FTL-* > ${{ matrix.bin_name }}.sha1
-
name: Upload artifacts to job for later processing
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v3
with:
name: tmp-binary-storage
path: '${{ matrix.bin_name }}*'
deploy:
if: github.event_name != 'pull_request'
needs: build
runs-on: ubuntu-latest
steps:
-
name: Get Binaries built in previous jobs
uses: actions/download-artifact@v3
with:
name: tmp-binary-storage
-
name: Display structure of downloaded files
run: ls -R
-
name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
-
name: Transfer Builds to Pi-hole server for pihole checkout
run: |
sftp -b - ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} <<< "-mkdir ${{ needs.build.outputs.OUTPUT_DIR }}
put * ${{ needs.build.outputs.OUTPUT_DIR }}"
-
name: Attach binaries to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
*