Merge pull request #2543 from DL6ER/fix/fork_prs

Fix foreign fork PRs
This commit is contained in:
Adam Warner
2025-07-03 11:13:35 +01:00
committed by GitHub

View File

@@ -26,6 +26,7 @@ jobs:
GIT_TAG: ${{ steps.variables.outputs.GIT_TAG }}
GIT_BRANCH: ${{ steps.variables.outputs.GIT_BRANCH }}
OUTPUT_DIR: ${{ steps.variables.outputs.OUTPUT_DIR }}
DO_DEPLOY: ${{ steps.variables.outputs.DO_DEPLOY }}
runs-on: ubuntu-latest
steps:
@@ -42,6 +43,7 @@ jobs:
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_OUTPUT
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
echo "OUTPUT_DIR=${GIT_TAG:-${GIT_BRANCH}}" >> $GITHUB_OUTPUT
echo "DO_DEPLOY=${{ github.event_name != 'pull_request' && secrets.SSH_KEY != '' && github.actor != 'dependabot[bot]' }}" >> $GITHUB_OUTPUT
-
name: "Check git branch name depth"
env:
@@ -94,6 +96,7 @@ jobs:
CI_ARCH: ${{ matrix.platform }}
GIT_BRANCH: ${{ needs.smoke-tests.outputs.GIT_BRANCH }}
GIT_TAG: ${{ needs.smoke-tests.outputs.GIT_TAG }}
DO_DEPLOY: ${{ needs.smoke-tests.outputs.DO_DEPLOY }}
steps:
-
name: Checkout code
@@ -122,8 +125,8 @@ jobs:
--pull \
--load \
--build-arg "CI_ARCH=${{ matrix.platform }}" \
--build-arg "GIT_BRANCH=${{ needs.smoke-tests.outputs.GIT_BRANCH }}" \
--build-arg "GIT_TAG=${{ needs.smoke-tests.outputs.GIT_TAG }}" \
--build-arg "GIT_BRANCH=${{ env.GIT_BRANCH }}" \
--build-arg "GIT_TAG=${{ env.GIT_TAG }}" \
--build-arg "BUILD_OPTS=${{ matrix.build_opts }}" \
--tag ftl-builder:local \
--file .github/Dockerfile .
@@ -165,8 +168,7 @@ jobs:
mv pihole-FTL "${{ matrix.bin_name }}"
sha1sum pihole-FTL-* > ${{ matrix.bin_name }}.sha1
-
name: Store binary artifacts for later deployment
if: github.event_name != 'pull_request'
name: Upload pihole-FTL binary
uses: actions/upload-artifact@v4.6.2
with:
name: ${{ matrix.bin_name }}-binary
@@ -176,25 +178,26 @@ jobs:
uses: actions/attest-build-provenance@v2.3.0
# Skip attestation if ACTIONS_ID_TOKEN_REQUEST_URL env variable is not
# available (e.g., PR originating from a fork)
if: ${{ env.ACTIONS_ID_TOKEN_REQUEST_URL != '' }}
if: env.DO_DEPLOY == 'true' && env.ACTIONS_ID_TOKEN_REQUEST_URL != ''
with:
subject-path: ${{ matrix.bin_name }}
-
name: Upload documentation artifacts for deployment
if: github.event_name != 'pull_request' && matrix.platform == 'linux/amd64' && matrix.build_opts == ''
name: Upload documentation files
if: matrix.bin_name == 'pihole-FTL-amd64'
uses: actions/upload-artifact@v4.6.2
with:
name: pihole-api-docs
path: 'api-docs.tar.gz'
-
name: Upload pihole.toml artifacts for deployment
if: github.event_name != 'pull_request' && matrix.platform == 'linux/amd64' && matrix.build_opts == ''
name: Upload pihole.toml template
if: matrix.bin_name == 'pihole-FTL-amd64'
uses: actions/upload-artifact@v4.6.2
with:
name: pihole-toml
path: 'pihole.toml'
-
name: Get binaries built in previous jobs
if: env.DO_DEPLOY == 'true'
uses: actions/download-artifact@v4.3.0
id: download
with:
@@ -203,25 +206,27 @@ jobs:
merge-multiple: true
-
name: Get documentation files built in previous jobs
if: matrix.bin_name == 'pihole-FTL-amd64'
if: env.DO_DEPLOY == 'true' && matrix.bin_name == 'pihole-FTL-amd64'
uses: actions/download-artifact@v4.3.0
with:
path: ftl_builds/
name: pihole-api-docs
-
name: Get pihole.toml built in previous job
if: matrix.bin_name == 'pihole-FTL-amd64'
if: env.DO_DEPLOY == 'true' && matrix.bin_name == 'pihole-FTL-amd64'
uses: actions/download-artifact@v4.3.0
with:
path: ftl_builds/
name: pihole-toml
-
name: Display structure of downloaded files
if: env.DO_DEPLOY == 'true'
shell: bash
run: ls -R
working-directory: ${{steps.download.outputs.download-path}}
-
name: Install SSH Key
if: env.DO_DEPLOY == 'true'
uses: benoitchantre/setup-ssh-authentication-action@1.0.1
with:
private-key: ${{ secrets.SSH_KEY }}
@@ -229,11 +234,12 @@ jobs:
known-hosts: ${{ secrets.KNOWN_HOSTS }}
-
name: Set private key permissions
if: env.DO_DEPLOY == 'true'
shell: bash
run: chmod 600 ~/.ssh/id_rsa
-
name: Untar documentation files
if: matrix.bin_name == 'pihole-FTL-amd64'
if: env.DO_DEPLOY == 'true' && matrix.bin_name == 'pihole-FTL-amd64'
working-directory: ftl_builds/
shell: bash
run: |
@@ -241,12 +247,13 @@ jobs:
tar xzvf api-docs.tar.gz -C docs/
-
name: Display structure of files ready for upload
if: env.DO_DEPLOY == 'true'
working-directory: ftl_builds/
shell: bash
run: ls -R
-
name: Transfer Builds to Pi-hole server for pihole checkout
if: github.actor != 'dependabot[bot]'
if: env.DO_DEPLOY == 'true'
env:
USER: ${{ secrets.SSH_USER }}
HOST: ${{ secrets.SSH_HOST }}