Skip to content

Commit f2f8bdb

Browse files
authored
Add create_branch job for Ephemeral Environments (#374)
* Add create branch job * Drop requirement
1 parent e8047a0 commit f2f8bdb

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

.github/workflows/_ephemeral_environment_manager.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
workflow_call:
66
inputs:
77
ephemeral_env_branch:
8-
required: true
98
type: string
109
project:
1110
type: string
@@ -14,6 +13,8 @@ on:
1413
type: boolean
1514
sync_environment:
1615
type: boolean
16+
create_branch:
17+
type: boolean
1718
pull_request_number:
1819
type: number
1920
workflow_dispatch:
@@ -40,6 +41,39 @@ jobs:
4041
name: Check PR run
4142
uses: ./.github/workflows/check-run.yml
4243

44+
create-branch:
45+
name: Create Branch
46+
if: ${{ inputs.create_branch }}
47+
runs-on: ubuntu-24.04
48+
needs: check-run
49+
steps:
50+
- name: Login to Azure - Prod Subscription
51+
uses: Azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0
52+
with:
53+
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
54+
55+
- name: Retrieve secrets
56+
id: retrieve-secrets
57+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
58+
with:
59+
keyvault: ${{ env._KEY_VAULT }}
60+
secrets: "github-pat-bitwarden-devops-bot-repo-scope,github-bitwarden-devops-bot-email"
61+
62+
- name: Checkout Ephemeral Environment Charts
63+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
64+
with:
65+
repository: bitwarden/ephemeral-environments
66+
token: '${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }}'
67+
68+
- name: Create Branch
69+
env:
70+
BRANCH_NAME: ee-${{ inputs.project }}-${{ inputs.pull_request_number }}
71+
run: |
72+
if ! git rev-parse --verify origin/${{ env.BRANCH_NAME }}; then
73+
git checkout -b ${{ env.BRANCH_NAME }}
74+
git push
75+
fi
76+
4377
cleanup:
4478
name: Cleanup config
4579
if: ${{ inputs.cleanup_config }}

0 commit comments

Comments
 (0)