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

Make workflows conditional on access to secrets #390

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 22 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
outputs:
has-secrets: ${{ steps.check-secrets.outputs.has-secrets }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Node.js version
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14.x'

Expand All @@ -37,18 +39,35 @@ jobs:
cp web.config public/

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: node-app
path: ./public/

- name: Check for secrets
id: check-secrets
env:
has_secrets: >-
${{
secrets.AZURE_CLIENT_ID != '' &&
secrets.AZURE_TENANT_ID != '' &&
secrets.AZURE_SUBSCRIPTION_ID != '' &&
1 ||
''
}}
if: env.has_secrets
run: |
echo 'has-secrets=1' >> "$GITHUB_OUTPUT"

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

if: needs.build.outputs.has-secrets

steps:
- name: Az CLI login
uses: azure/login@v1
Expand Down
27 changes: 23 additions & 4 deletions .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
outputs:
has-secrets: ${{ steps.check-secrets.outputs.has-secrets }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Node.js version
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14.x'

Expand All @@ -32,23 +34,40 @@ jobs:
run: |
node ./script/redirects.js

- name: Copy rewrites to server root
- name: Copy redirects to server root
run: |
cp web.config public/

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: node-app
path: ./public/

- name: Check for secrets
id: check-secrets
env:
has_secrets: >-
${{
secrets.AZURE_STAGING_CLIENT_ID != '' &&
secrets.AZURE_TENANT_ID != '' &&
secrets.AZURE_SUBSCRIPTION_ID != '' &&
1 ||
''
}}
if: env.has_secrets
run: |
echo 'has-secrets=1' >> "$GITHUB_OUTPUT"

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'staging'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

if: needs.build.outputs.has-secrets

steps:
- name: Az CLI login
uses: azure/login@v1
Expand Down