Skip to content

Commit

Permalink
get rid of passing repository name. conditionally pass elevated-githu…
Browse files Browse the repository at this point in the history
…b-token in ENT
  • Loading branch information
jmurret committed Mar 30, 2023
1 parent db1d130 commit b2c671d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-distros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
runs-on: ${{ needs.setup.outputs.compute-medium }}
repository-name: ${{ github.repository }}
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"

build-386:
needs:
Expand Down
40 changes: 14 additions & 26 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ jobs:
uses: ./.github/workflows/reusable-check-go-mod.yml
with:
runs-on: ${{ needs.setup.outputs.compute-small }}
repository-name: ${{ github.repository }}
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"

check-generated-protobuf:
needs:
Expand Down Expand Up @@ -157,7 +156,7 @@ jobs:
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"

lint-32bit:
needs:
Expand All @@ -168,7 +167,7 @@ jobs:
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"

# create a development build
dev-build:
Expand All @@ -177,9 +176,8 @@ jobs:
uses: ./.github/workflows/reusable-dev-build.yml
with:
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"

# TODO(JM): - linux arm64 is not available in our self-hosted runners
# they are currently on the roadmap.
Expand Down Expand Up @@ -214,10 +212,9 @@ jobs:
directory: .
runner-count: 12
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: ""
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-enterprise:
Expand All @@ -229,10 +226,9 @@ jobs:
directory: .
runner-count: 12
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-race:
Expand All @@ -245,10 +241,9 @@ jobs:
go-test-flags: 'GO_TEST_FLAGS="-race -gcflags=all=-d=checkptr=0"'
package-names-command: "go list ./... | grep -E -v '^github.com/hashicorp/consul/agent(/consul|/local|/routine-leak-checker)?$' | grep -E -v '^github.com/hashicorp/consul/command/'"
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-32bit:
Expand All @@ -261,10 +256,9 @@ jobs:
go-arch: "386"
go-test-flags: 'export GO_TEST_FLAGS="-short"'
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-envoyextensions:
Expand All @@ -275,10 +269,9 @@ jobs:
with:
directory: envoyextensions
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-troubleshoot:
Expand All @@ -289,10 +282,9 @@ jobs:
with:
directory: troubleshoot
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-api-1-19:
Expand All @@ -303,10 +295,9 @@ jobs:
with:
directory: api
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-api-1-20:
Expand All @@ -317,10 +308,9 @@ jobs:
with:
directory: api
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-sdk-1-19:
Expand All @@ -331,10 +321,9 @@ jobs:
with:
directory: sdk
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

go-test-sdk-1-20:
Expand All @@ -345,10 +334,9 @@ jobs:
with:
directory: sdk
runs-on: ${{ needs.setup.outputs.compute-xl }}
repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
elevated-github-token: "${{ endsWith(github.repository, '-enterprise') && secrets.ELEVATED_GITHUB_TOKEN || '' }}"
consul-license: ${{secrets.CONSUL_LICENSE}}

noop:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/reusable-check-go-mod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ on:
description: An expression indicating which kind of runners to use.
required: true
type: string
repository-name:
required: true
type: string
secrets:
elevated-github-token:
required: true
env:
ELEVATED_GITHUB_TOKEN: ${{ secrets.elevated-github-token }}
jobs:
check-go-mod:
runs-on: ${{ fromJSON(inputs.runs-on) }}
Expand All @@ -21,8 +20,8 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
- name: Setup Git
if: ${{ endsWith(inputs.repository-name, '-enterprise') }}
run: git config --global url."https://${{ secrets.elevated-github-token }}:@github.com".insteadOf "https://github.com"
if: ${{ env.ELEVATED_GITHUB_TOKEN != "" }}
run: git config --global url."https://${{ env.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
with:
go-version-file: 'go.mod'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/reusable-dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ on:
description: An expression indicating which kind of runners to use.
required: true
type: string
repository-name:
required: true
type: string
secrets:
elevated-github-token:
required: true
env:
ELEVATED_GITHUB_TOKEN: ${{ secrets.elevated-github-token }}

jobs:
build:
runs-on: ${{ fromJSON(inputs.runs-on) }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
- name: Setup Git
if: ${{ endsWith(inputs.repository-name, '-enterprise') }}
run: git config --global url."https://${{ secrets.elevated-github-token }}:@github.com".insteadOf "https://github.com"
if: ${{ env.ELEVATED_GITHUB_TOKEN != "" }}
run: git config --global url."https://${{ env.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
with:
go-version-file: 'go.mod'
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/reusable-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
env:
GOTAGS: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consulprem consuldev' || '' }}"
GOARCH: ${{inputs.go-arch}}
ELEVATED_GITHUB_TOKEN: ${{ secrets.elevated-github-token }}

jobs:
lint:
Expand All @@ -39,8 +40,8 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
- name: Setup Git
if: ${{ endsWith(inputs.repository-name, '-enterprise') }}
run: git config --global url."https://${{ secrets.elevated-github-token }}:@github.com".insteadOf "https://github.com"
if: ${{ env.ELEVATED_GITHUB_TOKEN != "" }}
run: git config --global url."https://${{ env.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
with:
go-version-file: 'go.mod'
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/reusable-unit-split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ on:
required: false
type: string
default: ""
repository-name:
required: true
type: string
go-tags:
required: false
type: string
Expand All @@ -49,6 +46,7 @@ env:
TOTAL_RUNNERS: ${{inputs.runner-count}}
CONSUL_LICENSE: ${{secrets.consul-license}}
GOTAGS: ${{ inputs.go-tags}}
ELEVATED_GITHUB_TOKEN: ${{ secrets.elevated-github-token }}

jobs:
set-test-package-matrix:
Expand Down Expand Up @@ -82,8 +80,8 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
- name: Setup Git
if: ${{ endsWith(inputs.repository-name, '-enterprise') }}
run: git config --global url."https://${{ secrets.elevated-github-token }}:@github.com".insteadOf "https://github.com"
if: ${{ env.ELEVATED_GITHUB_TOKEN != "" }}
run: git config --global url."https://${{ env.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
with:
go-version-file: 'go.mod'
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/reusable-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ on:
required: false
type: string
default: ""
repository-name:
required: true
type: string
go-tags:
required: false
type: string
Expand All @@ -44,16 +41,17 @@ env:
GOARCH: ${{inputs.go-arch}}
CONSUL_LICENSE: ${{secrets.consul-license}}
GOTAGS: ${{ inputs.go-tags}}

ELEVATED_GITHUB_TOKEN: ${{ secrets.elevated-github-token }}

jobs:
go-test:
runs-on: ${{ fromJSON(inputs.runs-on) }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
- name: Setup Git
if: ${{ endsWith(inputs.repository-name, '-enterprise') }}
run: git config --global url."https://${{ secrets.elevated-github-token }}:@github.com".insteadOf "https://github.com"
if: ${{ env.ELEVATED_GITHUB_TOKEN != "" }}
run: git config --global url."https://${{ env.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
with:
go-version-file: 'go.mod'
Expand Down

0 comments on commit b2c671d

Please sign in to comment.