Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
fix: use specify team when creating app with app.json
Browse files Browse the repository at this point in the history
  • Loading branch information
pmbanugo committed May 4, 2022
1 parent 1d87f41 commit 42535b3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The action expects a few input parameters which are defined below.
- region (optional): The region to deploy to. For example `eu` or `us`. Default: `eu`
- stack (optional): The Heroku stack to deploy and build with e.g heroku-18. Default: `heroku-20`. If the input `use-app-json` is `true`, the stack will be determined by what's in `app.json`, and if not present, the default on Heroku will be used.
- use-app-json (optional): Set up the initial build using the `app.json` in the root directory. Default: `false`.
- team (optional): The Heroku team the app belongs to.

## What's next?

Expand Down
22 changes: 21 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
description: "Heroku stack to deploy to e.g heroku-18. Default: heroku-20"
default: "heroku-20"
required: false
team:
description: "The Heroku team the app belongs to."
required: false
use-app-json:
description: "Set up the initial build using app.json. For more info: https://devcenter.heroku.com/articles/setting-up-apps-using-the-heroku-platform-api"
default: false
Expand Down Expand Up @@ -85,7 +88,7 @@ runs:
-H "Accept: application/vnd.heroku+json; version=3" \
-H "Authorization: Bearer ${{ inputs.api-key }}"
- name: "Create App (Setup with app.json)"
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened') && inputs.use-app-json == 'true' }}
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened') && inputs.use-app-json == 'true' && inputs.team == '' }}
shell: bash
run: |
export SOURCE_GET_URL=$(echo ${{ toJSON(steps.source_endpoint.outputs.SOURCE_ENDPOINT) }} | jq -r '.get')
Expand All @@ -100,6 +103,23 @@ runs:
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3" \
-H "Authorization: Bearer ${{ inputs.api-key }}"
- name: "Create Team App (Setup with app.json)"
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened') && inputs.use-app-json == 'true' && inputs.team != '' }}
shell: bash
run: |
export SOURCE_GET_URL=$(echo ${{ toJSON(steps.source_endpoint.outputs.SOURCE_ENDPOINT) }} | jq -r '.get')
curl -X POST https://api.heroku.com/app-setups \
-d '{
"source_blob": {"url": "'"$SOURCE_GET_URL"'", "version": "'"${{ github.event.pull_request.head.sha }}"'"},
"app": {
"name": "'"$APP_NAME"'",
"region": "${{ inputs.region }}",
"organization": "${{ inputs.team }}"
}
}' \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3" \
-H "Authorization: Bearer ${{ inputs.api-key }}"
- name: Update Pipeline
if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened') }}
shell: bash
Expand Down

0 comments on commit 42535b3

Please sign in to comment.