|
18 | 18 | jobs: |
19 | 19 | upload: |
20 | 20 | runs-on: ubuntu-latest |
| 21 | + # Only run on manual dispatch, |
| 22 | + # OR if the parent run succeeded and was triggered by a PR from |
| 23 | + # a branch in the main repo (not a fork) |
21 | 24 | if: | |
22 | 25 | github.event_name == 'workflow_dispatch' || |
23 | 26 | ( |
24 | 27 | github.event_name == 'workflow_run' && |
25 | 28 | github.event.workflow_run.event == 'pull_request' && |
26 | | - github.event.workflow_run.conclusion == 'success' |
| 29 | + github.event.workflow_run.conclusion == 'success' && |
| 30 | + github.event.workflow_run.head_repository.full_name == github.repository |
27 | 31 | ) |
28 | 32 | steps: |
29 | 33 | - name: Get required metadata (PR number, commit SHA, workflow run ID containing artifacts) |
|
49 | 53 | exit 1 |
50 | 54 | fi |
51 | 55 |
|
52 | | - # If PR_NUM is empty (this is the case for forks) get PR number using SHA |
| 56 | + # If PR_NUM is empty, get PR number using SHA |
53 | 57 | if [ -z "${PR_NUM}" ]; then |
54 | 58 | PR_NUM=$(gh pr list --search "sha:${SHA}" --state open --json number --jq '.[0].number') |
55 | 59 | fi |
@@ -139,15 +143,16 @@ jobs: |
139 | 143 | run: | |
140 | 144 | # Move 'pr-NNNN/' directory into upload directory inside repo and cd into repo root |
141 | 145 | TARGET_DIR="${UPLOAD_DIR_NAME}/pr-${PR_NUM}" |
142 | | - cp -r ${TARGET_DIR} plotly.js-dev-builds/ |
| 146 | + mkdir -p "plotly.js-dev-builds/${UPLOAD_DIR_NAME}" |
| 147 | + cp -r "${TARGET_DIR}" "plotly.js-dev-builds/${UPLOAD_DIR_NAME}" |
143 | 148 | cd plotly.js-dev-builds |
144 | 149 |
|
145 | 150 | # Configure git |
146 | 151 | git config user.name "plotly.js-pr-upload" |
147 | 152 | git config user.email "<>" |
148 | 153 |
|
149 | 154 | # Add files |
150 | | - git add ${TARGET_DIR}/ |
| 155 | + git add "${TARGET_DIR}/" |
151 | 156 |
|
152 | 157 | # Ensure that only files in upload/pr-NNNN/ are staged |
153 | 158 | if git diff --name-only --cached | grep -qv "^${TARGET_DIR}/"; then |
|
0 commit comments