Skip to content

Building Azure Infrastructure #52

Building Azure Infrastructure

Building Azure Infrastructure #52

Workflow file for this run

name: ci
on: pull_request
jobs:
go-lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v4
- name: Run linters
uses: golangci/golangci-lint-action@v5
with:
version: latest
args: --timeout=3m
go-test:
strategy:
matrix:
go-version: [1.22.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
- name: go tests
run: (set -o pipefail && go test -v -covermode=count -json ./... | tee test.json)
- name: annotate go tests
if: always()
uses: guyarb/golang-test-annotations@v0.5.1
with:
test-results: test.json
test:
runs-on: ubuntu-latest
env:
BATON_LOG_LEVEL: debug
BATON: ./baton/baton
BATON_AZURE_CLIENT_ID: ${{ secrets.BATON_AZURE_CLIENT_ID }}
BATON_AZURE_CLIENT_SECRET: ${{ secrets.BATON_AZURE_CLIENT_SECRET }}
BATON_AZURE_TENANT_ID: ${{ secrets.BATON_AZURE_TENANT_ID }}
BATON_ENTITLEMENT: "resource_group_role_assignment:test_2_resource_group:39ea64c5-86d5-4c29-8199-5b602c90e1c5:11102f94-c441-49e6-a78b-ef80e0188abc:assigned"
BATON_PRINCIPAL_TYPE: "user"
BATON_PRINCIPAL: "e4e9c5ae-2937-408b-ba3c-0f58cf417f0a"
BATON_GRANT: "resource_group_role_assignment:test_2_resource_group:39ea64c5-86d5-4c29-8199-5b602c90e1c5:11102f94-c441-49e6-a78b-ef80e0188abc:assigned:user:e4e9c5ae-2937-408b-ba3c-0f58cf417f0a"
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x
- name: Checkout code
uses: actions/checkout@v4
- name: Build baton-azure-infrastructure
run: go build ./cmd/baton-azure-infrastructure
- name: Run baton-azure-infrastructure
env:
BATON_AZURE_CLIENT_ID: ${{ secrets.BATON_AZURE_CLIENT_ID }}
BATON_AZURE_CLIENT_SECRET: ${{ secrets.BATON_AZURE_CLIENT_SECRET }}
BATON_AZURE_TENANT_ID: ${{ secrets.BATON_AZURE_TENANT_ID }}
run: ./baton-azure-infrastructure
- name: Install baton
run: ./scripts/get-baton.sh && mv baton /usr/local/bin
- name: Check for grant before revoking
run: |
./baton-azure-infrastructure
baton grants --entitlement="${{ env.BATON_ENTITLEMENT }}" --output-format=json | jq --exit-status 'if .grants then .grants | any(.principal.id.resource == "${{ env.BATON_PRINCIPAL }}") else . end'
- name: Revoke grants
run: |
./baton-azure-infrastructure
./baton-azure-infrastructure --revoke-grant ${{ env.BATON_GRANT }}
- name: Check grant was revoked
run: |
./baton-azure-infrastructure
baton grants --entitlement="${{ env.BATON_ENTITLEMENT }}" --output-format=json | jq --exit-status "if .grants then .grants[]?.principal.id.resource != \"${{ env.BATON_PRINCIPAL }}\" else . end"
- name: Grant entitlement
run: |
./baton-azure-infrastructure
./baton-azure-infrastructure --grant-entitlement ${{ env.BATON_ENTITLEMENT }} --grant-principal-type ${{ env.BATON_PRINCIPAL_TYPE }} --grant-principal ${{ env.BATON_PRINCIPAL }} --provisioning
- name: Check grant was re-granted
run: |
./baton-azure-infrastructure
baton grants --entitlement ${{ env.BATON_ENTITLEMENT }} --output-format=json | jq -e ".grants | any(.principal.id.resource ==\"${{ env.BATON_PRINCIPAL }}\")"