Skip to content

chore: add access verification before live and action tests #251

chore: add access verification before live and action tests

chore: add access verification before live and action tests #251

Workflow file for this run

name: Continuous Integration
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
contents: read
jobs:
tests-unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Install Dependencies
id: npm-ci
run: npm ci
- name: Lint
id: npm-lint
run: npm run lint
- name: Test
id: npm-test
run: npm run test
check-access:
name: Check Secrets Access
runs-on: ubuntu-latest
outputs:
access_verified: ${{ steps.check-access.outputs.verified && !(github.event_name == 'workflow_dispatch' && github.ref != 'refs/head/main') }}
steps:
- id: check-access
if: env.SECRET_TO_CHECK != ''
run: echo 'verified=true' >> $GITHUB_OUTPUT
env:
SECRET_TO_CHECK: ${{ secrets.SECRET_TO_CHECK }}
tests-live:
permissions:
contents: read
id-token: write
if: needs.check-access.outputs.access_verified == 'true'
needs:
- check-access
name: Live Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Install Dependencies
id: npm-ci
run: npm ci
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Run Live Tests
run: npm run test:live
env:
LIVETEST_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
LIVETEST_RESOURCE_GROUP: azure-bicep-deploy-ci
tests-action:
permissions:
contents: read
id-token: write
if: needs.check-access.outputs.access_verified == 'true'
needs:
- check-access
name: Actions Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
concurrency:
# Stacks are stateful - avoid modifying the same Stack concurrently
group: ${{ matrix.os }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Test Deployment - Validate
uses: ./
with:
type: deployment
operation: validate
name: ci-deploy-${{ matrix.os }}
scope: resourceGroup
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resource-group-name: azure-bicep-deploy-ci
parameters-file: test/files/basic/main.bicepparam
- name: Test Deployment - WhatIf
uses: ./
with:
type: deployment
operation: whatIf
name: ci-deploy-${{ matrix.os }}
scope: resourceGroup
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resource-group-name: azure-bicep-deploy-ci
parameters-file: test/files/basic/main.bicepparam
- name: Test Deployment - Deploy
uses: ./
with:
type: deployment
operation: create
name: ci-deploy-${{ matrix.os }}
scope: resourceGroup
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resource-group-name: azure-bicep-deploy-ci
parameters-file: test/files/basic/main.bicepparam
- name: Test Local Action (Stack)
uses: ./
with:
type: deploymentStack
operation: create
name: ci-stack-${{ matrix.os }}
scope: resourceGroup
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resource-group-name: azure-bicep-deploy-ci
parameters-file: test/files/basic/main.bicepparam
action-on-unmanage-resources: delete
deny-settings-mode: denyDelete