Skip to content

Commit

Permalink
ci(fix): run ghcr build in DevOps workflow for forks
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobLichterfeld committed Oct 19, 2024
1 parent 773a58e commit 688147e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/devops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ jobs:
needs:
- check_paths
- elixir_dep_verification_and_static_analysis
# Only run if there are no changes to the github folder and for PR from non-forks
if: needs.check_paths.outputs.githubfolder != 'true' && ( ${{ github.event.pull_request.head.repo.full_name }} == ${{ github.repository }}) || github.event_name == 'schedule'
if: needs.check_paths.outputs.githubfolder != 'true'
uses: ./.github/workflows/ghcr_build.yml
16 changes: 7 additions & 9 deletions .github/workflows/ghcr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Build GHCR images

on:
workflow_call:
pull_request_target:
branches: ["master"]
paths:
- "**/*"
Expand All @@ -25,8 +24,7 @@ jobs:
teslamate_build:
name: Build images
needs: check_paths
# Only run if there are no changes to the github folder and on workflow call, or PRs from forks (to avoid duplicate runs for PRs from non-forks, and to avoid invalid reference format for cache name in PRs from our repo)
if: needs.check_paths.outputs.githubfolder != 'true' && (${{ github.event_name == 'workflow_call' }} || ${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }})
if: needs.check_paths.outputs.githubfolder != 'true'
strategy:
fail-fast: false
matrix:
Expand All @@ -45,9 +43,10 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
if: ${{ github.event_name != 'pull_request_target' }}
if: ${{ github.event.pull_request.head.repo.full_name }} == ${{ github.repository }}
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
if: ${{ github.event_name == 'pull_request_target' }}
# coming from a fork
if: ${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }}
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
Expand Down Expand Up @@ -88,14 +87,13 @@ jobs:

grafana:
needs: check_paths
# Only run if there are no changes to the github folder and on workflow call, or PRs from forks (to avoid duplicate runs for PRs from non-forks, and to avoid invalid reference format for cache name in PRs from our repo)
if: needs.check_paths.outputs.githubfolder != 'true' && (${{ github.event_name == 'workflow_call' }} || ${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }})
if: needs.check_paths.outputs.githubfolder != 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
if: ${{ github.event_name != 'pull_request_target' }}
if: ${{ github.event.pull_request.head.repo.full_name }} == ${{ github.repository }}
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
if: ${{ github.event_name == 'pull_request_target' }}
if: ${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }}
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
Expand Down

0 comments on commit 688147e

Please sign in to comment.