Skip to content

Commit 7d518e4

Browse files
authored
CI External (#668)
* try authorize step * checkout right version * build.yml: fixup jobs * environment
1 parent 812b0d8 commit 7d518e4

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

.github/workflows/build.yaml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
name: Test Container
22

33
on:
4+
pull_request_target:
5+
branches:
6+
- main
47
pull_request:
58
branches:
69
- main
710

811
jobs:
12+
authorize:
13+
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository)
14+
runs-on: ubuntu-latest
15+
environment:
16+
${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
17+
steps:
18+
- run: |
19+
true
920
lint:
21+
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository)
1022
runs-on: rehosting-arc
23+
needs: authorize
1124
steps:
12-
- uses: actions/checkout@v4
13-
if: github.event_name == 'pull_request'
25+
- uses: actions/checkout@v5
26+
with:
27+
fetch-depth: 0
28+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
1429
- name: Set up Python
15-
if: github.event_name == 'pull_request'
1630
uses: actions/setup-python@v2
1731
with:
1832
python-version: "3.10"
1933
- name: Install dependencies
20-
if: github.event_name == 'pull_request'
2134
run: pip install flake8 lintly markupsafe==2.0.1
2235
- name: Lint with flake8
23-
if: github.event_name == 'pull_request'
2436
run: |
2537
set -o pipefail
2638
(flake8 | lintly) 2>lintly.err || {
@@ -37,9 +49,7 @@ jobs:
3749

3850
build_container:
3951
runs-on: rehosting-arc
40-
permissions:
41-
contents: write
42-
packages: write
52+
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository)
4353
needs: lint
4454

4555
steps:
@@ -88,6 +98,7 @@ jobs:
8898
type=registry,ref=${{secrets.REHOSTING_ARC_REGISTRY}}/rehosting/penguin:cache-PR-${{ github.event.number }}
8999
90100
run_tests:
101+
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository)
91102
needs: build_container
92103
runs-on: rehosting-arc
93104
strategy:
@@ -104,9 +115,10 @@ jobs:
104115
if: github.event_name == 'pull_request'
105116
run: pip install click pyyaml
106117
- name: Checkout code
107-
uses: actions/checkout@v4
118+
uses: actions/checkout@v5
108119
with:
109120
fetch-depth: 0
121+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
110122

111123
- name: Trust Harbor's self-signed certificate
112124
run: |

0 commit comments

Comments
 (0)