Skip to content

Commit 0ff2479

Browse files
committed
Refactor: Simplify Copilot setup workflow by removing unnecessary steps and improving permissions
1 parent 52c31fd commit 0ff2479

File tree

1 file changed

+10
-68
lines changed

1 file changed

+10
-68
lines changed
Lines changed: 10 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,33 @@
11
name: "Copilot Setup Steps"
22

3-
# Automatically run the setup steps when they are changed to allow for easy validation, and
4-
# allow manual testing through the repository's "Actions" tab
53
on:
64
workflow_dispatch:
75

86
permissions:
97
id-token: write
108
contents: read
11-
issues: write
129

1310
jobs:
14-
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
1511
copilot-setup-steps:
1612
runs-on: ubuntu-latest
17-
18-
# Set the permissions to the lowest permissions possible needed for your steps.
19-
# Copilot will be given its own token for its operations.
2013
permissions:
21-
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
22-
contents: write
2314
id-token: write
15+
contents: read
16+
environment: copilot # Must be exactly 'copilot' (lowercase) to match federated credential
2417

25-
# You can define any steps you want, and they will run before the agent starts.
26-
# If you do not check out your code, Copilot will do this for you.
2718
steps:
28-
- name: Checkout code
29-
uses: actions/checkout@v5
30-
31-
- name: Debug - Check if secrets are accessible
32-
run: |
33-
echo "Checking if secrets are set..."
34-
35-
ERROR_COUNT=0
36-
37-
if [ -z "${{ secrets.ARM_CLIENT_ID }}" ]; then
38-
echo "ERROR: ARM_CLIENT_ID is empty or not set"
39-
ERROR_COUNT=$((ERROR_COUNT + 1))
40-
else
41-
echo "✓ ARM_CLIENT_ID is set"
42-
fi
43-
44-
if [ -z "${{ secrets.ARM_TENANT_ID }}" ]; then
45-
echo "ERROR: ARM_TENANT_ID is empty or not set"
46-
ERROR_COUNT=$((ERROR_COUNT + 1))
47-
else
48-
echo "✓ ARM_TENANT_ID is set"
49-
fi
50-
51-
if [ -z "${{ secrets.ARM_SUBSCRIPTION_ID }}" ]; then
52-
echo "ERROR: ARM_SUBSCRIPTION_ID is empty or not set"
53-
ERROR_COUNT=$((ERROR_COUNT + 1))
54-
else
55-
echo "✓ ARM_SUBSCRIPTION_ID is set"
56-
fi
57-
58-
if [ $ERROR_COUNT -gt 0 ]; then
59-
echo ""
60-
echo "FATAL: $ERROR_COUNT required secret(s) missing."
61-
echo "Please verify secrets are configured as Repository secrets (not environment secrets)."
62-
echo "Go to: Settings → Secrets and variables → Actions → Repository secrets"
63-
exit 1
64-
fi
65-
66-
echo ""
67-
echo "All required secrets are present. Proceeding with Azure login..."
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
6821

69-
# Get OIDC token and login to Azure using federated identity
70-
- name: Azure CLI Login with Federated Identity
22+
- name: Azure login
7123
uses: azure/login@v2
7224
with:
73-
client-id: ${{ secrets.ARM_CLIENT_ID }}
74-
tenant-id: ${{ secrets.ARM_TENANT_ID }}
75-
subscription-id: ${{ secrets.ARM_SUBSCRIPTION_ID }}
76-
enable-AzPSSession: false
25+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
26+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
27+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
7728

78-
- name: Verify and persist Azure authentication
29+
- name: Verify Azure access
7930
run: |
80-
echo "Verifying Azure authentication..."
81-
az account show
82-
az group list --output table
83-
84-
# Verify the Azure config directory exists and has auth tokens
85-
ls -la ~/.azure/
86-
87-
echo "Azure CLI authentication successful!"
88-
echo "Auth tokens are cached in ~/.azure/ and will persist for this runner session"
89-
echo "Copilot will use these cached credentials"
31+
echo "Successfully authenticated to Azure!"
9032
az account show
9133
az group list --output table

0 commit comments

Comments
 (0)