Skip to content

Commit eee10fa

Browse files
authored
Install AZ CLI instead of using GitHub Actions
1 parent 15c56c2 commit eee10fa

1 file changed

Lines changed: 91 additions & 80 deletions

File tree

.github/actions/azdo-build/action.yml

Lines changed: 91 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: 'Build via AzDO'
2+
description: Run a build pipeline via Azure DevOps and download the build artifact
23

34
inputs:
45
artifact-name:
@@ -66,6 +67,18 @@ runs:
6667
# Docker is required for azure/cli
6768
- uses: docker/setup-docker-action@v5
6869

70+
- name: Install AZ CLI
71+
run: |
72+
if ! command -v az > /dev/null; then
73+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
74+
fi
75+
76+
if ! command -v jq > /dev/null; then
77+
sudo apt-get update
78+
sudo apt-get install -y jq
79+
fi
80+
shell: bash
81+
6982
- uses: azure/login@v2
7083
with:
7184
allow-no-subscriptions: true
@@ -116,96 +129,94 @@ runs:
116129
shell: bash
117130

118131
- name: Wait for pipeline completion
119-
uses: azure/cli@v2
120-
with:
121-
inlineScript: |
122-
set -e -o pipefail
123-
124-
az extension add --name azure-devops --only-show-errors
125-
126-
RUN_ID="${{ steps.run-pipeline.outputs.run-id }}"
127-
echo "Waiting for run ID: $RUN_ID to complete..."
128-
129-
# Timeout after 45 minutes (2700 seconds)
130-
TIMEOUT=2700
131-
ELAPSED=0
132-
INTERVAL=5
133-
134-
while [ $ELAPSED -lt $TIMEOUT ]; do
135-
OUTPUT=$(
136-
az pipelines runs show \
137-
--id "$RUN_ID" \
138-
--org ${{ inputs.azdo-org }} \
139-
--project ${{ inputs.azdo-project }} \
140-
--detect false \
141-
--output json
142-
)
143-
STATUS=$(echo "$OUTPUT" | jq -r '.status')
144-
145-
if [ -z "$STATUS" ] || [ "$STATUS" = "null" ]; then
146-
echo "Failed to extract status from output"
147-
exit 1
148-
fi
149-
150-
echo "Current status: $STATUS (elapsed: ${ELAPSED}s)"
132+
run: |
133+
set -e -o pipefail
134+
135+
az extension add --name azure-devops --only-show-errors
136+
137+
RUN_ID="${{ steps.run-pipeline.outputs.run-id }}"
138+
echo "Waiting for run ID: $RUN_ID to complete..."
139+
140+
# Timeout after 45 minutes (2700 seconds)
141+
TIMEOUT=2700
142+
ELAPSED=0
143+
INTERVAL=5
144+
145+
while [ $ELAPSED -lt $TIMEOUT ]; do
146+
OUTPUT=$(
147+
az pipelines runs show \
148+
--id "$RUN_ID" \
149+
--org ${{ inputs.azdo-org }} \
150+
--project ${{ inputs.azdo-project }} \
151+
--detect false \
152+
--output json
153+
)
154+
STATUS=$(echo "$OUTPUT" | jq -r '.status')
155+
156+
if [ -z "$STATUS" ] || [ "$STATUS" = "null" ]; then
157+
echo "Failed to extract status from output"
158+
exit 1
159+
fi
151160
152-
# Check for terminal states
153-
if [ "$STATUS" = "completed" ]; then
154-
echo "Pipeline completed!"
155-
RESULT=$(echo "$OUTPUT" | jq -r '.result')
156-
echo "Result: $RESULT"
161+
echo "Current status: $STATUS (elapsed: ${ELAPSED}s)"
157162
158-
if [ "$RESULT" != "succeeded" ]; then
159-
echo "Pipeline failed with result: $RESULT"
160-
exit 1
161-
fi
163+
# Check for terminal states
164+
if [ "$STATUS" = "completed" ]; then
165+
echo "Pipeline completed!"
166+
RESULT=$(echo "$OUTPUT" | jq -r '.result')
167+
echo "Result: $RESULT"
162168
163-
echo "Pipeline succeeded!"
164-
exit 0
165-
elif [ "$STATUS" = "canceling" ] || [ "$STATUS" = "canceled" ]; then
166-
echo "Pipeline was canceled"
169+
if [ "$RESULT" != "succeeded" ]; then
170+
echo "Pipeline failed with result: $RESULT"
167171
exit 1
168172
fi
169173
170-
sleep $INTERVAL
171-
ELAPSED=$((ELAPSED + INTERVAL))
172-
done
174+
echo "Pipeline succeeded!"
175+
exit 0
176+
elif [ "$STATUS" = "canceling" ] || [ "$STATUS" = "canceled" ]; then
177+
echo "Pipeline was canceled"
178+
exit 1
179+
fi
173180
174-
echo "Timeout reached after ${TIMEOUT} seconds for run ID: $RUN_ID"
175-
exit 1
181+
sleep $INTERVAL
182+
ELAPSED=$((ELAPSED + INTERVAL))
183+
done
184+
185+
echo "Timeout reached after ${TIMEOUT} seconds for run ID: $RUN_ID"
186+
exit 1
187+
shell: bash
176188

177189
- name: Download artifact from Azure DevOps
178-
uses: azure/cli@v2
179-
with:
180-
inlineScript: |
181-
set -e -o pipefail
182-
183-
tdnf install -y icu
184-
tdnf install -y jq
185-
az extension add --name azure-devops --only-show-errors
186-
187-
RUN_ID="${{ steps.run-pipeline.outputs.run-id }}"
188-
echo "Downloading artifact 'drop_build_main' from run ID: $RUN_ID"
189-
190-
# Create directory for artifact
191-
mkdir -p ./artifact-download/
192-
193-
# Download the artifact
194-
az pipelines runs artifact download \
195-
--artifact-name "drop_build_main" \
196-
--detect false \
197-
--org ${{ inputs.azdo-org }} \
198-
--path "$GITHUB_WORKSPACE/artifact-download/" \
199-
--project ${{ inputs.azdo-project }} \
200-
--run-id "$RUN_ID"
201-
202-
# Verify artifact was downloaded
203-
if [ -z "$(ls -A artifact-download)" ]; then
204-
echo "Artifact directory is empty after download"
205-
exit 1
206-
fi
190+
run: |
191+
set -e -o pipefail
192+
193+
tdnf install -y icu
194+
tdnf install -y jq
195+
az extension add --name azure-devops --only-show-errors
196+
197+
RUN_ID="${{ steps.run-pipeline.outputs.run-id }}"
198+
echo "Downloading artifact 'drop_build_main' from run ID: $RUN_ID"
199+
200+
# Create directory for artifact
201+
mkdir -p ./artifact-download/
202+
203+
# Download the artifact
204+
az pipelines runs artifact download \
205+
--artifact-name "drop_build_main" \
206+
--detect false \
207+
--org ${{ inputs.azdo-org }} \
208+
--path "$GITHUB_WORKSPACE/artifact-download/" \
209+
--project ${{ inputs.azdo-project }} \
210+
--run-id "$RUN_ID"
211+
212+
# Verify artifact was downloaded
213+
if [ -z "$(ls -A artifact-download)" ]; then
214+
echo "Artifact directory is empty after download"
215+
exit 1
216+
fi
207217
208-
echo "Artifact downloaded successfully"
218+
echo "Artifact downloaded successfully"
219+
shell: bash
209220

210221
- name: Upload artifact
211222
uses: actions/upload-artifact@v6

0 commit comments

Comments
 (0)