Skip to content

We need to get the MAX(id) from the on-disk database even if database… #2437

We need to get the MAX(id) from the on-disk database even if database…

We need to get the MAX(id) from the on-disk database even if database… #2437

Workflow file for this run

name: Build, Test, Deploy
on:
push:
branches:
- '**'
pull_request:
release:
types: [published]
jobs:
smoke-tests:
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
steps:
-
name: Checkout code
uses: actions/checkout@v3.5.3
-
name: "Calculate required 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 "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_OUTPUT
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
echo "OUTPUT_DIR=${GIT_TAG:-${GIT_BRANCH}}" >> $GITHUB_OUTPUT
-
name: "Check git branch name depth"
env:
GIT_BRANCH: ${{ steps.variables.outputs.GIT_BRANCH }}
run: |
IFS='/';
read -r -a branch <<<"${GIT_BRANCH}";
if [[ "${#branch[@]}" -gt 2 ]]; then echo "Error: Your branch name contains more than one subdir, which will cause issues with the build process." && FAIL=1; fi;
unset IFS;
# If FAIL is 1 then we fail.
[[ $FAIL == 1 ]] && exit 1 || echo "Branch name depth check passed."
shell: bash
build:
runs-on: ubuntu-latest
needs: smoke-tests
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
bin_name: pihole-FTL-amd64
builder: alpine
- platform: linux/386
bin_name: pihole-FTL-386
builder: alpine
- platform: linux/arm/v5
bin_name: pihole-FTL-armv4
builder: debian
- platform: linux/arm/v6
bin_name: pihole-FTL-armv5
builder: debian
- platform: linux/arm/v6
bin_name: pihole-FTL-armv6
builder: alpine
- platform: linux/arm/v7
bin_name: pihole-FTL-armv7
builder: alpine
- platform: linux/arm64/v8
bin_name: pihole-FTL-arm64
builder: alpine
- platform: linux/riscv64
bin_name: pihole-FTL-riscv64
builder: alpine
env:
CI_ARCH: ${{ matrix.platform }}
GIT_BRANCH: ${{ needs.smoke-tests.outputs.GIT_BRANCH }}
GIT_TAG: ${{ needs.smoke-tests.outputs.GIT_TAG }}
steps:
-
name: Checkout code
uses: actions/checkout@v3.5.3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.9.1
-
name: Print directory contents
run: ls -l
-
name: Build and test FTL in ftl-build container (QEMU)
uses: docker/build-push-action@v4.1.1
with:
# tags: ghcr.io/pi-hole/ftl-build:v2.0
platforms: ${{ matrix.platform }}
# Always load latest container image
pull: true
# Do not push anything
push: false
context: .
target: result
file: .github/Dockerfile
outputs: |
type=tar,dest=build.tar
build-args: |
"BUILDER=${{ matrix.builder }}"
"CI_ARCH=${{ matrix.platform }}"
"GIT_BRANCH=${{ needs.smoke-tests.outputs.GIT_BRANCH }}"
"GIT_TAG=${{ needs.smoke-tests.outputs.GIT_TAG }}"
-
name: List files in current directory
run: ls -l
-
name: Extract FTL binary from container
run: |
tar -xf build.tar pihole-FTL
-
name: "Generate checksum file"
run: |
mv pihole-FTL "${{ matrix.bin_name }}"
sha1sum pihole-FTL-* > ${{ matrix.bin_name }}.sha1
-
name: Store binary artifacts for later deployoment
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v3.1.2
with:
name: tmp-storage
path: '${{ matrix.bin_name }}*'
-
name: Extract documentation files from container
if: github.event_name != 'pull_request' && matrix.platform == 'linux/amd64'
run: |
tar -xf build.tar api-docs.tar.gz
-
name: Upload documentation artifacts for deployoment
if: github.event_name != 'pull_request' && matrix.platform == 'linux/amd64'
uses: actions/upload-artifact@v3.1.2
with:
name: tmp-storage
path: 'api-docs.tar.gz'
deploy:
if: github.event_name != 'pull_request'
needs: [smoke-tests, build]
runs-on: ubuntu-latest
steps:
-
name: Checkout code
uses: actions/checkout@v3.5.3
-
name: Get Binaries and documentation built in previous jobs
uses: actions/download-artifact@v3.0.2
id: download
with:
name: tmp-storage
path: ftl-builds/
-
name: Display structure of downloaded files
run: ls -R
working-directory: ${{steps.download.outputs.download-path}}
-
name: Install SSH Key
uses: benoitchantre/setup-ssh-authentication-action@1.0.1
with:
private-key: ${{ secrets.SSH_KEY }}
known-hosts: ${{ secrets.KNOWN_HOSTS }}
-
name: Untar documentation files
working-directory: ${{steps.download.outputs.download-path}}
run: |
mkdir docs/
tar xzvf api-docs.tar.gz -C docs/
-
name: Display structure of files ready for upload
run: ls -R
working-directory: ${{steps.download.outputs.download-path}}
-
name: Transfer Builds to Pi-hole server for pihole checkout
if: github.actor != 'dependabot[bot]'
env:
USER: ${{ secrets.SSH_USER }}
HOST: ${{ secrets.SSH_HOST }}
TARGET_DIR: ${{ needs.smoke-tests.outputs.OUTPUT_DIR }}
SOURCE_DIR: ${{ steps.download.outputs.download-path }}
run: |
bash ./deploy.sh
-
name: Attach binaries to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
${{ steps.download.outputs.download-path }}/*