From a636fb9cd6de8a8b2dced97daedb1dc4f5de67a8 Mon Sep 17 00:00:00 2001 From: Jeremy Moore Date: Wed, 19 Jun 2024 21:46:15 -0400 Subject: [PATCH] dev-plan workflow --- .github/workflows/dev_deploy.yml | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/dev_deploy.yml diff --git a/.github/workflows/dev_deploy.yml b/.github/workflows/dev_deploy.yml new file mode 100644 index 000000000..811bf615f --- /dev/null +++ b/.github/workflows/dev_deploy.yml @@ -0,0 +1,60 @@ +--- +name: Create Dev Deployment + +on: + pull_request: + types: [labeled] + +env: + TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TERRAFORM_API_TOKEN }} + ORGANIZATION: science-and-design + PROJECT: Hush Line Dev + +jobs: + deploy: + if: ${{ github.event.label.name == 'dev-deploy' }} + runs-on: ubuntu-latest + steps: + - name: checkout terraform + uses: actions/checkout@v4 + with: + repository: 'scidsg/hushline-infra' + ref: dev-deploy + token: ${{ secrets.HUSHLINE_INFRA_TOKEN }} + + - name: Use branch workspace + uses: dflook/terraform-new-workspace@v1.43.0 + with: + path: terraform/dev + workspace: dev-${{ github.head_ref }} + + - name: Update workspace attributes + run: | + curl -X PATCH https://app.terraform.io/api/v2/organizations/science-and-design/workspaces/dev-${{ github.head_ref }} \ + -H 'Content-Type: application/vnd.api+json' \ + -H 'Authorization: Bearer ${{ secrets.TERRAFORM_API_TOKEN }}' \ + -d '{ + "data": { + "type": "workspaces", + "attributes": { + "working-directory": "terraform/dev", + }, + "relationships": { + "project": { + "data": { + "id": "Hush Line Dev" + } + } + } + } + }' + + - name: Plan test infrastrucutre + uses: dflook/terraform-plan@v1.43.0 + with: + path: terraform/dev + workspace: dev-${{ github.head_ref }} + add_github_comment: false + variables: | + tag = "latest" + name = "hushline-${{ github.head_ref }}"