Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-62724: update secrets for github_action #83

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions .github/workflows/build_and_release_gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ name: Ruby Gem to RubyGems
# - TRACE_BUILD_RUBY_ACTIONS_API_TOKEN (from the trace-build user in github)
# - RUBYGEMS_TOKEN (from the solarwinds-apm user on rubygems.org)
# - APM_RUBY_INSTALL_TESTING_SWO_KEY
# - CI_GITHUB_TOKEN
#
# The correct oboe version has to be in the file ext/oboe_metal/src/VERSION

Expand Down Expand Up @@ -72,10 +71,17 @@ jobs:
echo "local and rubygems checksum not matching, gem needs to be yanked from rubygems.org"
exit 1

- name: Obtain github token
uses: getsentry/action-github-app-token@v2
id: github-token
with:
app_id: ${{ vars.APPLICATION_ID }}
private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}

- name: Create release draft that includes the checksum
uses: actions/github-script@v3
with:
github-token: ${{secrets.CI_GITHUB_TOKEN}}
github-token: ${{ steps.github-token.outputs.token }}
Copy link
Contributor

@cheempz cheempz Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, this was changed from the automatic GITHUB_TOKEN... does it not work for create release (even if given higher privilege) and we really need an Admin-level token like secrets.APPLICATION_PRIVATE_KEY?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated wrong link in above comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TRACE_BUILD_RUBY_ACTIONS_API_TOKEN (e.g. TRACE_BUILD_TOKEN in the action file) is used in https://github.com/solarwindscloud/swotel-ruby/blob/main/Rakefile#L96-L99. This is a legacy method that verify the oboe file is consistent with the aws bucket downloaded.

For the create release, probably only need the contents: write permission (ref)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's leave the TRACE_BUILD_RUBY_ACTIONS_API_TOKEN as-is then, that Rake task might be useful.

For creating the release, can you update line 84 to use the automatic GITHUB_TOKEN instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can then remove the Obtain github token step.

script: |
github.repos.createRelease({
owner: "solarwindscloud",
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/verify_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ jobs:
matrix: ${{ steps.launch.outputs.matrix }} # this will be a json object mapping identifiers to labels and instance ids
runs-on: ubuntu-latest
steps:
- uses: getsentry/action-github-app-token@v2
id: github-token
with:
app_id: ${{ vars.APPLICATION_ID }}
private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}

- uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.CI_ACCESS_KEY_ID }}
Expand All @@ -49,7 +55,7 @@ jobs:
amazonlinux:2
amazonlinux:2023
ubuntu:22.04
github-token: ${{ secrets.CI_GITHUB_TOKEN }}
github-token: ${{ steps.github-token.outputs.token }}
runner-user: github
runner-directory: /gh
instance-type: t4g.medium
Expand Down Expand Up @@ -121,6 +127,12 @@ jobs:
- verify_installation
runs-on: ubuntu-latest
steps:
- uses: getsentry/action-github-app-token@v2
id: github-token
with:
app_id: ${{ vars.APPLICATION_ID }}
private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}

- uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.CI_ACCESS_KEY_ID }}
Expand All @@ -129,5 +141,5 @@ jobs:
- uses: solarwindscloud/ec2-runner-action@main
with:
action: terminate
github-token: ${{ secrets.CI_GITHUB_TOKEN }}
github-token: ${{ steps.github-token.outputs.token }}
matrix: ${{ needs.start_arm64_runner.outputs.matrix }} # passing a matrix will terminate all runners, not just one