Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@ on:
pull_request:
types: [closed]
branches: [main]
delete:
branches-ignore: [main]

env:
GH_HEAD_REF: ${{ github.head_ref }}
GH_REF: ${{ github.ref_name }}

permissions:
id-token: write
contents: read

jobs:
deploy:
if: github.event_name != 'delete' && !(github.event_name == 'pull_request' && github.event.action == 'closed')
name: Deploy Project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Set up Python
Expand All @@ -38,3 +47,43 @@ jobs:

- name: Deploy Project
run: obproject-deploy
env:
PYTHONUNBUFFERED: "1"

teardown:
if: >
(github.event_name == 'delete') ||
(github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true)
name: Teardown Branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: pip install outerbounds ob-project-utils pyyaml

- name: Configure Outerbounds
run: |
PROJECT_NAME=$(yq .project obproject.toml)
PLATFORM=$(yq .platform obproject.toml)
CICD_USER="${PROJECT_NAME//_/-}-cicd"
outerbounds service-principal-configure \
--name $CICD_USER \
--deployment-domain $PLATFORM \
--perimeter default \
--github-actions

- name: Teardown branch resources
run: |
BRANCH=${{ github.head_ref || github.event.ref }}
PROJECT=$(yq .project obproject.toml)
echo "Tearing down $PROJECT/$BRANCH"
outerbounds flowproject teardown-branch \
--id "$PROJECT/$BRANCH" --yes -o json
Loading