Skip to content

Commit

Permalink
Merge branch 'develop' into feature/SCALRCORE-27395
Browse files Browse the repository at this point in the history
  • Loading branch information
DayS1eeper committed Jul 24, 2023
2 parents 6f999d6 + 8ae9d68 commit 32e739f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
SCALR_TOKEN: ${{ secrets.SCALR_TOKEN }}
UPSTREAM_ID: ${{ github.run_number }}
steps:
- name: Sudo GitHub Token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{vars.SUDO_GHA_APP_ID}}
installation_id: ${{vars.SUDO_GHA_APP_INSTALLATION_ID}}
private_key: ${{secrets.SUDO_GHA_APP_PRIVATE_KEY}}
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
Expand All @@ -32,7 +39,7 @@ jobs:
id: check-branch
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_PAT }}
github-token: ${{steps.generate_token.outputs.token}}
script: |
const owner = "Scalr";
const repo = "fatmouse";
Expand Down Expand Up @@ -63,7 +70,7 @@ jobs:
repository: Scalr/fatmouse
path: fatmouse
ref: ${{ steps.check-branch.outputs.branch }}
token: ${{ secrets.GH_PAT }}
token: ${{steps.generate_token.outputs.token}}
- name: Set DB_BRANCH
if: ${{ contains(github.event.head_commit.message, '[DB_BRANCH]') }}
run: echo "DB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ jobs:
SCALR_TOKEN: ${{ secrets.SCALR_TOKEN }}
UPSTREAM_ID: ${{ github.run_number }}
steps:
- name: Sudo GitHub Token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{vars.SUDO_GHA_APP_ID}}
installation_id: ${{vars.SUDO_GHA_APP_INSTALLATION_ID}}
private_key: ${{secrets.SUDO_GHA_APP_PRIVATE_KEY}}
- uses: actions/checkout@v3
- name: Log pr link
run: |
Expand All @@ -40,7 +47,7 @@ jobs:
- name: Set pending status
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GH_PAT }}
github-token: ${{steps.generate_token.outputs.token}}
script: |
github.repos.createCommitStatus({
owner: 'Scalr',
Expand All @@ -60,7 +67,7 @@ jobs:
repository: Scalr/fatmouse
path: fatmouse
ref: ${{ inputs.pr_branch }}
token: ${{ secrets.GH_PAT }}
token: ${{steps.generate_token.outputs.token}}
- name: Set DB_BRANCH
if: ${{ contains(github.event.head_commit.message, '[DB_BRANCH]') }}
run: echo "DB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
Expand Down Expand Up @@ -134,7 +141,7 @@ jobs:
if: ${{ always() && (steps.run-tests.outcome == 'failure' || steps.run-tests.outcome == 'success') }}
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GH_PAT }}
github-token: ${{steps.generate_token.outputs.token}}
script: |
github.repos.createCommitStatus({
owner: 'Scalr',
Expand All @@ -149,7 +156,7 @@ jobs:
if: ${{ always() && steps.run-tests.outcome != 'failure' && steps.run-tests.outcome != 'success' }}
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GH_PAT }}
github-token: ${{steps.generate_token.outputs.token}}
script: |
github.repos.createCommitStatus({
owner: 'Scalr',
Expand All @@ -170,7 +177,7 @@ jobs:
const repo = '${{ inputs.repo }}';
const message = '**go-scalr tests failed**\nJob url ${{ steps.get-job-id.outputs.html_url }}';
await github.rest.issues.createComment({owner, repo, issue_number, body: message});
github-token: ${{ secrets.GH_PAT }}
github-token: ${{steps.generate_token.outputs.token}}
- name: Delete container
id: delete
if: ${{ always() }}
Expand Down
10 changes: 10 additions & 0 deletions scalr.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,5 +555,15 @@ func checkResponseCode(r *http.Response) error {
}
}

if r.StatusCode == 403 {
return fmt.Errorf(
"The Scalr Terraform provider has been configured with an access token that lacks sufficient permissions." +
" If you are running remotely, follow the documentation (https://docs.scalr.io/docs/scalr) on how to " +
"enable the Scalr provider configuration in the remote workspace. " +
"If running locally, ensure you have enough permissions to perform actions." +
"\n Errors: " + strings.Join(errs, "\n"),
)
}

return fmt.Errorf(strings.Join(errs, "\n"))
}

0 comments on commit 32e739f

Please sign in to comment.