mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Reduce code duplication by outsourcing into composite actions
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
name: Build and test
|
||||
description: Builds and tests FTL on all supported platforms
|
||||
|
||||
inputs:
|
||||
platform:
|
||||
required: true
|
||||
description: The platform to build for
|
||||
git_branch:
|
||||
required: true
|
||||
description: The branch to build from
|
||||
git_tag:
|
||||
required: true
|
||||
description: The tag to build from (if any)
|
||||
bin_name:
|
||||
required: true
|
||||
description: The name of the binary to build
|
||||
artifact_name:
|
||||
required: true
|
||||
description: The name of the artifact to upload
|
||||
event_name:
|
||||
required: true
|
||||
description: The name of the event that triggered the workflow run
|
||||
|
||||
# Both the definition of environment variables and checking out the code
|
||||
# needs to be done outside of the composite action as
|
||||
# - environment variables cannot be defined using inputs
|
||||
# - the checkout action needs to be the first step in the workflow, otherwise we
|
||||
# cannot use the composite action as the corresponding "action.yml" isn't
|
||||
# there yet
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.1.0
|
||||
-
|
||||
name: Print directory contents
|
||||
shell: bash
|
||||
run: ls -l
|
||||
-
|
||||
name: Build and test FTL in ftl-build container (QEMU)
|
||||
uses: Wandalen/wretry.action@v1.4.5
|
||||
with:
|
||||
attempt_limit: 3
|
||||
action: docker/build-push-action@v5.0.0
|
||||
with: |
|
||||
platforms: ${{ inputs.platform }}
|
||||
pull: true
|
||||
push: false
|
||||
context: .
|
||||
target: result
|
||||
file: .github/Dockerfile
|
||||
outputs: |
|
||||
type=tar,dest=build.tar
|
||||
build-args: |
|
||||
"CI_ARCH=${{ inputs.platform }}"
|
||||
"GIT_BRANCH=${{ inputs.git_branch }}"
|
||||
"GIT_TAG=${{ inputs.git_tag }}"
|
||||
-
|
||||
name: List files in current directory
|
||||
shell: bash
|
||||
run: ls -l
|
||||
-
|
||||
name: Extract FTL binary from container
|
||||
shell: bash
|
||||
run: |
|
||||
tar -xf build.tar pihole-FTL
|
||||
-
|
||||
name: "Generate checksum file"
|
||||
shell: bash
|
||||
run: |
|
||||
mv pihole-FTL "${{ inputs.bin_name }}"
|
||||
sha1sum pihole-FTL-* > ${{ inputs.bin_name }}.sha1
|
||||
-
|
||||
name: Store binary artifacts for later deployoment
|
||||
if: inputs.event_name != 'pull_request'
|
||||
uses: actions/upload-artifact@v4.3.1
|
||||
with:
|
||||
name: ${{ inputs.artifact_name }}
|
||||
path: '${{ inputs.bin_name }}*'
|
||||
-
|
||||
name: Extract documentation files from container
|
||||
if: inputs.event_name != 'pull_request' && inputs.platform == 'linux/amd64'
|
||||
shell: bash
|
||||
run: |
|
||||
tar -xf build.tar api-docs.tar.gz
|
||||
-
|
||||
name: Upload documentation artifacts for deployoment
|
||||
if: inputs.event_name != 'pull_request' && inputs.platform == 'linux/amd64'
|
||||
uses: actions/upload-artifact@v4.3.1
|
||||
with:
|
||||
name: pihole-api-docs
|
||||
path: 'api-docs.tar.gz'
|
||||
@@ -0,0 +1,83 @@
|
||||
name: Deploy
|
||||
description: Deploy the FTL binary and documentation
|
||||
|
||||
inputs:
|
||||
pattern:
|
||||
required: true
|
||||
description: The pattern to match the artifacts to download
|
||||
target_dir:
|
||||
required: true
|
||||
description: The directory to deploy the artifacts to
|
||||
event_name:
|
||||
required: true
|
||||
description: The name of the event that triggered the workflow run
|
||||
actor:
|
||||
required: true
|
||||
description: The name of the user or app that initiated the workflow run
|
||||
# Secrets cannot be accessed in the action.yml file so we need to pass them as
|
||||
# inputs to the action.
|
||||
SSH_KEY:
|
||||
required: true
|
||||
description: The SSH private key to use for authentication
|
||||
KNOWN_HOSTS:
|
||||
required: true
|
||||
description: The SSH known hosts file
|
||||
SSH_USER:
|
||||
required: true
|
||||
description: The SSH user to use for authentication
|
||||
SSH_HOST:
|
||||
required: true
|
||||
description: The SSH host to connect to
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
-
|
||||
name: Get Binaries and documentation built in previous jobs
|
||||
uses: actions/download-artifact@v4.1.4
|
||||
id: download
|
||||
with:
|
||||
path: ftl_builds/
|
||||
pattern: ${{ inputs.pattern }}
|
||||
merge-multiple: true
|
||||
-
|
||||
name: Display structure of downloaded files
|
||||
shell: bash
|
||||
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: ${{ inputs.SSH_KEY }}
|
||||
known-hosts: ${{ inputs.KNOWN_HOSTS }}
|
||||
-
|
||||
name: Untar documentation files
|
||||
working-directory: ftl_builds/
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir docs/
|
||||
tar xzvf api-docs.tar.gz -C docs/
|
||||
-
|
||||
name: Display structure of files ready for upload
|
||||
working-directory: ftl_builds/
|
||||
shell: bash
|
||||
run: ls -R
|
||||
-
|
||||
name: Transfer Builds to Pi-hole server for pihole checkout
|
||||
if: inputs.actor != 'dependabot[bot]'
|
||||
env:
|
||||
USER: ${{ inputs.SSH_USER }}
|
||||
HOST: ${{ inputs.SSH_HOST }}
|
||||
TARGET_DIR: ${{ inputs.target_dir }}
|
||||
SOURCE_DIR: ftl_builds/
|
||||
shell: bash
|
||||
run: |
|
||||
bash ./deploy.sh
|
||||
-
|
||||
name: Attach binaries to release
|
||||
if: inputs.event_name == 'release'
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
ftl_builds/*
|
||||
+43
-253
@@ -61,148 +61,46 @@ jobs:
|
||||
bin_name: pihole-FTL-amd64
|
||||
- platform: linux/386
|
||||
bin_name: pihole-FTL-386
|
||||
|
||||
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@v4.1.1
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.1.0
|
||||
-
|
||||
name: Print directory contents
|
||||
run: ls -l
|
||||
-
|
||||
name: Build and test FTL in ftl-build container (QEMU)
|
||||
uses: Wandalen/wretry.action@v1.4.5
|
||||
name: Build and test FTL
|
||||
uses: ./.github/actions/build-and-test
|
||||
with:
|
||||
attempt_limit: 3
|
||||
action: docker/build-push-action@v5.0.0
|
||||
with: |
|
||||
platforms: ${{ matrix.platform }}
|
||||
pull: true
|
||||
push: false
|
||||
context: .
|
||||
target: result
|
||||
file: .github/Dockerfile
|
||||
outputs: |
|
||||
type=tar,dest=build.tar
|
||||
build-args: |
|
||||
"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@v4.3.1
|
||||
with:
|
||||
name: ${{ matrix.bin_name }}-binary
|
||||
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@v4.3.1
|
||||
with:
|
||||
name: pihole-api-docs
|
||||
path: 'api-docs.tar.gz'
|
||||
platform: ${{ matrix.platform }}
|
||||
bin_name: ${{ matrix.bin_name }}
|
||||
artifact_name: ${{ matrix.bin_name }}-binary
|
||||
git_branch: ${{ needs.smoke-tests.outputs.GIT_BRANCH }}
|
||||
git_tag: ${{ needs.smoke-tests.outputs.GIT_TAG }}
|
||||
event_name: ${{ github.event_name }}
|
||||
|
||||
build-gha-riscv64:
|
||||
runs-on: ubuntu-latest
|
||||
needs: smoke-tests
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/riscv64
|
||||
bin_name: pihole-FTL-riscv64
|
||||
|
||||
env:
|
||||
CI_ARCH: ${{ matrix.platform }}
|
||||
CI_ARCH: linux/riscv64
|
||||
GIT_BRANCH: ${{ needs.smoke-tests.outputs.GIT_BRANCH }}
|
||||
GIT_TAG: ${{ needs.smoke-tests.outputs.GIT_TAG }}
|
||||
|
||||
steps:
|
||||
-
|
||||
name: Checkout code
|
||||
uses: actions/checkout@v4.1.1
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.1.0
|
||||
-
|
||||
name: Print directory contents
|
||||
run: ls -l
|
||||
-
|
||||
name: Build and test FTL in ftl-build container (QEMU)
|
||||
uses: Wandalen/wretry.action@v1.4.5
|
||||
name: Build and test FTL
|
||||
uses: ./.github/actions/build-and-test
|
||||
with:
|
||||
attempt_limit: 3
|
||||
action: docker/build-push-action@v5.0.0
|
||||
with: |
|
||||
platforms: ${{ matrix.platform }}
|
||||
pull: true
|
||||
push: false
|
||||
context: .
|
||||
target: result
|
||||
file: .github/Dockerfile
|
||||
outputs: |
|
||||
type=tar,dest=build.tar
|
||||
build-args: |
|
||||
"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@v4.3.1
|
||||
with:
|
||||
name: riscv64-${{ matrix.bin_name }}-binary
|
||||
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@v4.3.1
|
||||
with:
|
||||
name: pihole-api-docs
|
||||
path: 'api-docs.tar.gz'
|
||||
platform: linux/riscv64
|
||||
bin_name: pihole-FTL-riscv64
|
||||
artifact_name: riscv64-pihole-FTL-riscv64-binary
|
||||
git_branch: ${{ needs.smoke-tests.outputs.GIT_BRANCH }}
|
||||
git_tag: ${{ needs.smoke-tests.outputs.GIT_TAG }}
|
||||
event_name: ${{ github.event_name }}
|
||||
|
||||
build-self-hosted:
|
||||
runs-on: self-hosted
|
||||
@@ -217,72 +115,24 @@ jobs:
|
||||
bin_name: pihole-FTL-armv7
|
||||
- platform: linux/arm64/v8
|
||||
bin_name: pihole-FTL-arm64
|
||||
|
||||
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@v4.1.1
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.1.0
|
||||
-
|
||||
name: Print directory contents
|
||||
run: ls -l
|
||||
-
|
||||
name: Build and test FTL in ftl-build container (QEMU)
|
||||
uses: Wandalen/wretry.action@v1.4.5
|
||||
name: Build and test FTL
|
||||
uses: ./.github/actions/build-and-test
|
||||
with:
|
||||
attempt_limit: 3
|
||||
action: docker/build-push-action@v5.0.0
|
||||
with: |
|
||||
platforms: ${{ matrix.platform }}
|
||||
pull: true
|
||||
push: false
|
||||
context: .
|
||||
target: result
|
||||
file: .github/Dockerfile
|
||||
outputs: |
|
||||
type=tar,dest=build.tar
|
||||
build-args: |
|
||||
"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@v4.3.1
|
||||
with:
|
||||
name: ${{ matrix.bin_name }}-binary
|
||||
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@v4.3.1
|
||||
with:
|
||||
name: pihole-api-docs
|
||||
path: 'api-docs.tar.gz'
|
||||
platform: ${{ matrix.platform }}
|
||||
bin_name: ${{ matrix.bin_name }}
|
||||
artifact_name: ${{ matrix.bin_name }}-binary
|
||||
git_branch: ${{ needs.smoke-tests.outputs.GIT_BRANCH }}
|
||||
git_tag: ${{ needs.smoke-tests.outputs.GIT_TAG }}
|
||||
event_name: ${{ github.event_name }}
|
||||
|
||||
deploy:
|
||||
if: github.event_name != 'pull_request'
|
||||
@@ -293,50 +143,17 @@ jobs:
|
||||
name: Checkout code
|
||||
uses: actions/checkout@v4.1.1
|
||||
-
|
||||
name: Get Binaries and documentation built in previous jobs
|
||||
uses: actions/download-artifact@v4.1.4
|
||||
id: download
|
||||
name: Build and test FTL
|
||||
uses: ./.github/actions/deploy
|
||||
with:
|
||||
path: ftl_builds/
|
||||
pattern: pihole-*
|
||||
merge-multiple: true
|
||||
-
|
||||
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: ftl_builds/
|
||||
run: |
|
||||
mkdir docs/
|
||||
tar xzvf api-docs.tar.gz -C docs/
|
||||
-
|
||||
name: Display structure of files ready for upload
|
||||
run: ls -R
|
||||
working-directory: ftl_builds/
|
||||
-
|
||||
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: ftl_builds/
|
||||
run: |
|
||||
bash ./deploy.sh
|
||||
-
|
||||
name: Attach binaries to release
|
||||
if: github.event_name == 'release'
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
ftl_builds/*
|
||||
target_dir: ${{ needs.smoke-tests.outputs.OUTPUT_DIR }}
|
||||
event_name: ${{ github.event_name }}
|
||||
actor: ${{ github.actor }}
|
||||
SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
KNOWN_HOSTS: ${{ secrets.KNOWN_HOSTS }}
|
||||
SSH_USER: ${{ secrets.SSH_USER }}
|
||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||
|
||||
deploy-riscv64:
|
||||
if: github.event_name != 'pull_request'
|
||||
@@ -347,41 +164,14 @@ jobs:
|
||||
name: Checkout code
|
||||
uses: actions/checkout@v4.1.1
|
||||
-
|
||||
name: Get Binaries and documentation built in previous jobs
|
||||
uses: actions/download-artifact@v4.1.4
|
||||
id: download
|
||||
name: Build and test FTL
|
||||
uses: ./.github/actions/deploy
|
||||
with:
|
||||
path: ftl_builds/
|
||||
pattern: riscv64-pihole-*
|
||||
merge-multiple: true
|
||||
-
|
||||
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: Display structure of files ready for upload
|
||||
run: ls -R
|
||||
working-directory: ftl_builds/
|
||||
-
|
||||
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: ftl_builds/
|
||||
run: |
|
||||
bash ./deploy.sh
|
||||
-
|
||||
name: Attach binaries to release
|
||||
if: github.event_name == 'release'
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
ftl_builds/*
|
||||
target_dir: ${{ needs.smoke-tests.outputs.OUTPUT_DIR }}
|
||||
event_name: ${{ github.event_name }}
|
||||
actor: ${{ github.actor }}
|
||||
SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
KNOWN_HOSTS: ${{ secrets.KNOWN_HOSTS }}
|
||||
SSH_USER: ${{ secrets.SSH_USER }}
|
||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||
|
||||
Reference in New Issue
Block a user