diff --git a/.github/workflows/build-android-target.yml b/.github/workflows/build-android-target.yml new file mode 100644 index 000000000..5d8bd430c --- /dev/null +++ b/.github/workflows/build-android-target.yml @@ -0,0 +1,35 @@ +# This workflow is intended to be run when we need to build the Android SDK 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. +# This should only be done after reviewing the PR to ensure that no malicious code has been introduced, +# as it could allow the code on the forked branch to have access to workflow secrets. + +name: Build Android on PR Target + +on: + pull_request_target: + types: [opened, synchronize, reopened] + branches: + - main + +defaults: + run: + shell: bash + +jobs: + check-run: + name: Check PR run + uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main + permissions: + contents: read + + run-workflow: + name: Build Android + needs: check-run + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + uses: ./.github/workflows/build-android.yml + secrets: inherit + permissions: + contents: read + pull-requests: write + id-token: write diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index c9523eeb4..9453cd3a6 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -11,6 +11,14 @@ on: description: "Update Android Repo - Opens a PR updating the SDK in bitwarden/android" type: boolean default: false + workflow_call: + secrets: + AZURE_SUBSCRIPTION_ID: + required: true + AZURE_TENANT_ID: + required: true + AZURE_CLIENT_ID: + required: true defaults: run: diff --git a/.github/workflows/build-wasm-internal-target.yml b/.github/workflows/build-wasm-internal-target.yml new file mode 100644 index 000000000..72ea6b330 --- /dev/null +++ b/.github/workflows/build-wasm-internal-target.yml @@ -0,0 +1,35 @@ +# This workflow is intended to be run when we need to build the WASM SDK 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. +# This should only be done after reviewing the PR to ensure that no malicious code has been introduced, +# as it could allow the code on the forked branch to have access to workflow secrets. + +name: Build @bitwarden/sdk-internal on PR Target + +on: + pull_request_target: + types: [opened, synchronize, reopened] + branches: + - main + +defaults: + run: + shell: bash + +jobs: + check-run: + name: Check PR run + uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main + permissions: + contents: read + + run-workflow: + name: Build @bitwarden/sdk-internal + needs: check-run + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + uses: ./.github/workflows/build-wasm-internal.yml + secrets: inherit + permissions: + contents: read + pull-requests: write + id-token: write diff --git a/.github/workflows/build-wasm-internal.yml b/.github/workflows/build-wasm-internal.yml index ac0d4253a..d2c31d62c 100644 --- a/.github/workflows/build-wasm-internal.yml +++ b/.github/workflows/build-wasm-internal.yml @@ -8,6 +8,14 @@ on: - "rc" - "hotfix-rc" workflow_dispatch: + workflow_call: + secrets: + AZURE_SUBSCRIPTION_ID: + required: true + AZURE_TENANT_ID: + required: true + AZURE_CLIENT_ID: + required: true permissions: {} diff --git a/.github/workflows/enforce-labels-target.yml b/.github/workflows/enforce-labels-target.yml new file mode 100644 index 000000000..642571011 --- /dev/null +++ b/.github/workflows/enforce-labels-target.yml @@ -0,0 +1,34 @@ +# This workflow is intended to be run when we need to enforce PR labels +# 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. +# This should only be done after reviewing the PR to ensure that no malicious code has been introduced, +# as it could allow the code on the forked branch to have access to workflow secrets. + +name: Enforce PR labels on PR Target + +on: + pull_request_target: + types: [labeled, unlabeled, opened, edited, synchronize] + branches: + - main + +defaults: + run: + shell: bash + +jobs: + check-run: + name: Check PR run + uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main + permissions: + contents: read + + run-workflow: + name: Enforce Labels + needs: check-run + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + uses: ./.github/workflows/enforce-labels.yml + secrets: inherit + permissions: + contents: read + pull-requests: read