Skip to content

Commit 06e6dc6

Browse files
committed
deploy: allow deploying in forks
It would be nice if we could deploy the Azure Function contingent on the presence of the `AZURE_CLIENT_ID` secret. However, this is not possible in GitHub workflows: the job-level `if:` conditions lack access to the `secrets` context. Strangely enough, they _do_ have access to the `vars` context... To successfully deploy the Azure Function, it needs to know which `gitgitgadget-workflows` fork to target when triggering workflow runs, anyway, so let's _require_ a repository variable called `DEPLOY_WITH_WORKFLOWS` that specifies that fork in the form `<org>/gitgitgadget-workflows`. Note that such a fork _must_ have the `CONFIG` repository variable that contains the corresponding project configuration; The `deploy` workflow will retrieve this configuration and overwrite `gitgitgadget-config.json` with it, augmenting the `workflowsRepo` information on the fly. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 30c4a1b commit 06e6dc6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ on:
1111

1212
jobs:
1313
deploy:
14-
if: github.event.repository.fork == false
14+
if: github.event.repository.fork == false || vars.DEPLOY_WITH_WORKFLOWS != ''
1515
environment: deploy-to-azure
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v5
19+
- name: retrieve `vars.CONFIG` from workflows repo
20+
if: vars.DEPLOY_WITH_WORKFLOWS != ''
21+
env:
22+
WORKFLOWS_REPO: '${{ vars.DEPLOY_WITH_WORKFLOWS }}'
23+
run: |
24+
WORKFLOWS_OWNER="${WORKFLOWS_REPO%%/*}" &&
25+
WORKFLOWS_NAME="${WORKFLOWS_REPO#*/}" &&
26+
gh variable get CONFIG --repo "$WORKFLOWS_REPO" |
27+
jq '. + { "workflowsRepo": { "owner": "'"$WORKFLOWS_OWNER"'", "name": "'"$WORKFLOWS_NAME"'" } }' \
28+
>GitGitGadget/gitgitgadget-config.json
1929
- name: 'Login via Azure CLI'
2030
uses: azure/login@v2
2131
with:

0 commit comments

Comments
 (0)