mirror of
https://github.com/bitwarden/clients.git
synced 2026-11-16 07:03:29 +00:00
68 lines
2.2 KiB
YAML
68 lines
2.2 KiB
YAML
# This workflow is intended to be run when we need to build the client and produce artifacts that require secrets
|
|
# when the PR source branch does not have access to secrets (e.g. a fork).
|
|
# This workflow will run in the context of the target of the PR and have access to secrets.
|
|
# It only runs when a user with write access adds the "ci:signed-build" label to a fork PR. Pushes to the PR branch
|
|
# (including "Update branch") do not trigger it. The label is removed once the build starts, so every new commit
|
|
# needs to be reviewed and labeled again. The label only starts this workflow when the PR changes CLI-related paths.
|
|
# Only add the label after reviewing the PR to ensure that no malicious code has been introduced,
|
|
# as it allows the code on the forked branch to have access to workflow secrets.
|
|
|
|
name: Build CLI (Fork PR)
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [labeled]
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'apps/cli/**'
|
|
- 'libs/**'
|
|
- '*'
|
|
- '!*.md'
|
|
- '!*.txt'
|
|
- '.github/workflows/build-cli.yml'
|
|
- 'bitwarden_license/bit-cli/**'
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
check-run:
|
|
name: Check PR run
|
|
if: ${{ github.event.label.name == 'ci:signed-build' && github.event.pull_request.head.repo.full_name != github.repository }}
|
|
uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main
|
|
permissions:
|
|
contents: read
|
|
|
|
remove-label:
|
|
name: Remove signed build label
|
|
needs: check-run
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
pull-requests: write
|
|
steps:
|
|
- name: Remove label
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
_PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
# Other fork build workflows share this label and may have already removed it.
|
|
run: |
|
|
if ! OUTPUT=$(gh api --method DELETE "repos/$GITHUB_REPOSITORY/issues/$_PR_NUMBER/labels/ci%3Asigned-build" 2>&1); then
|
|
if [[ "$OUTPUT" == *"HTTP 404"* ]]; then
|
|
echo "Label already removed."
|
|
else
|
|
echo "$OUTPUT"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
run-workflow:
|
|
name: Build CLI
|
|
needs: check-run
|
|
uses: ./.github/workflows/build-cli.yml
|
|
secrets: inherit
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|