Provide an input for github tokens (#172)

* Provide an input for github tokens

- By providing an input for github tokens with a default users no longer have to pass
  the github token via their environment across workflows.
- Remove GITHUB_TOKEN from our environment in all workflows

* Don't run workflows on main on pull requests

Co-authored-by: Paulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>
This commit is contained in:
Bryan Paxton
2023-01-06 10:14:27 -06:00
committed by GitHub
parent 81d8403713
commit e3f6ffe287
7 changed files with 22 additions and 21 deletions
+1 -5
View File
@@ -6,11 +6,7 @@ on:
branches:
- main
pull_request:
branches:
- main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
types: [opened, synchronize]
jobs:
check_integrity:
+1 -5
View File
@@ -6,11 +6,7 @@ on:
branches:
- main
pull_request:
branches:
- main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
types: [opened, synchronize]
jobs:
integration_test:
@@ -17,5 +17,3 @@ jobs:
node-version: '14'
- run:
./.github/workflows/update_3rd_party_licenses.sh
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
+1 -5
View File
@@ -6,11 +6,7 @@ on:
branches:
- main
pull_request:
branches:
- main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
types: [opened, synchronize]
jobs:
integration_test:
+9
View File
@@ -8,6 +8,15 @@ branding:
color: blue
icon: code
inputs:
github-token:
description: >
A GitHub token used to access the GitHub REST API for retrieving release and version information.
While this action will never perform anything more than read operations against the GitHub REST API,
we do not recommend providing a self-generated personal access token which may provide more access than is
required of this action. This input instead is merely a convenience so that users of this action do not
have to manually pass an automatically generated token via their environment settings within a workflow.
[Learn more about automatically generated tokens](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)
default: ${{ github.token }}
otp-version:
description: Version range or exact version of Erlang/OTP to use,
or false when installing only Gleam without OTP
+5 -2
View File
@@ -7612,9 +7612,12 @@ async function get(url0, pageIdxs) {
const headers = {
'user-agent': 'setup-beam',
}
if (process.env.GITHUB_TOKEN) {
headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`
const GithubToken = getInput('github-token', false)
if (GithubToken) {
headers.authorization = `Bearer ${GithubToken}`
}
if (pageIdx !== null) {
url.searchParams.append('page', pageIdx)
}
+5 -2
View File
@@ -419,9 +419,12 @@ async function get(url0, pageIdxs) {
const headers = {
'user-agent': 'setup-beam',
}
if (process.env.GITHUB_TOKEN) {
headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`
const GithubToken = getInput('github-token', false)
if (GithubToken) {
headers.authorization = `Bearer ${GithubToken}`
}
if (pageIdx !== null) {
url.searchParams.append('page', pageIdx)
}