Skip to content

Commit 673b8ae

Browse files
GHA-136 Fix S7630 (#62)
1 parent 33cea6a commit 673b8ae

3 files changed

Lines changed: 42 additions & 34 deletions

File tree

check-releasability-status/action.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,43 @@ runs:
2323
shell: bash
2424
env:
2525
GITHUB_TOKEN: ${{ inputs.github-token }}
26+
BRANCH_NAME: ${{ inputs.branch }}
27+
WITH_OPTIONAL_CHECKS: ${{ inputs.with-optional-checks }}
2628
run: |
27-
echo "Checking Releasability status on ${{ inputs.branch }} branch..."
28-
29+
echo "Checking Releasability status on $BRANCH_NAME branch..."
30+
2931
# Get the status for the specified branch
30-
STATUS_RESPONSE=$(gh api "/repos/${{ github.repository }}/commits/${{ inputs.branch }}/status" 2>/dev/null)
31-
32+
STATUS_RESPONSE=$(gh api "/repos/${{ github.repository }}/commits/$BRANCH_NAME/status" 2>/dev/null)
33+
3234
if [ $? -ne 0 ]; then
33-
echo "❌ Failed to get status information for ${{ inputs.branch }} branch"
35+
echo "❌ Failed to get status information for $BRANCH_NAME branch"
3436
exit 1
3537
fi
36-
38+
3739
# Find the Releasability status
3840
RELEASABILITY_STATE=$(echo "$STATUS_RESPONSE" | jq -r '.statuses[] | select(.context == "Releasability") | .state')
3941
RELEASABILITY_DESCRIPTION=$(echo "$STATUS_RESPONSE" | jq -r '.statuses[] | select(.context == "Releasability") | .description')
40-
42+
4143
if [ -z "$RELEASABILITY_STATE" ] || [ "$RELEASABILITY_STATE" = "null" ]; then
42-
echo "❌ Could not find Releasability status on ${{ inputs.branch }} branch"
44+
echo "❌ Could not find Releasability status on $BRANCH_NAME branch"
4345
exit 1
4446
fi
45-
47+
4648
echo "Found Releasability status: $RELEASABILITY_STATE"
4749
echo "Description: $RELEASABILITY_DESCRIPTION"
48-
50+
4951
# Check if state is success
5052
if [ "$RELEASABILITY_STATE" != "success" ]; then
5153
echo "❌ Releasability status is not success: $RELEASABILITY_STATE"
5254
exit 1
5355
fi
54-
56+
5557
# Check optional failures if requested
56-
if [ "${{ inputs.with-optional-checks }}" = "true" ]; then
58+
if [ "$WITH_OPTIONAL_CHECKS" = "true" ]; then
5759
if echo "$RELEASABILITY_DESCRIPTION" | grep -i "failed optional checks" > /dev/null; then
5860
echo "❌ Releasability status contains 'failed optional checks' in description"
5961
exit 1
6062
fi
6163
fi
62-
64+
6365
echo "✅ Releasability status check passed"

get-release-version/action.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ runs:
2525
shell: bash
2626
env:
2727
GITHUB_TOKEN: ${{ inputs.github-token }}
28+
BRANCH_NAME: ${{ inputs.branch }}
2829
run: |
2930
# Execute the gh CLI command to get the release version
30-
RELEASE_VERSION=$(gh api "/repos/${{ github.repository }}/commits/${{ inputs.branch }}/status" --jq ".statuses[] | select(.context | startswith(\"repox-${{ inputs.branch }}\")) | .description | split(\"'\")[1]")
31-
31+
RELEASE_VERSION=$(gh api "/repos/${{ github.repository }}/commits/$BRANCH_NAME/status" --jq ".statuses[] | select(.context | startswith(\"repox-$BRANCH_NAME\")) | .description | split(\"'\")[1]")
32+
3233
if [ -z "$RELEASE_VERSION" ]; then
3334
echo "❌ Could not extract release version from repox status"
3435
exit 1
3536
fi
36-
37+
3738
echo "✅ Extracted release version: $RELEASE_VERSION"
38-
39+
3940
# Set as output
4041
echo "release-version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
41-
42+
4243
# Set as environment variable
4344
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV

publish-github-release/action.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ runs:
6767
env:
6868
GITHUB_TOKEN: ${{ inputs.github-token }}
6969
HAS_RELEASE_NOTES: ${{ inputs.release-notes != '' }}
70+
BRANCH_NAME: ${{ inputs.branch }}
71+
DRAFT_MODE: ${{ inputs.draft }}
7072
run: |
7173
# Check if a release with the same title already exists
7274
EXPECTED_TITLE="$VALIDATED_VERSION"
@@ -77,8 +79,8 @@ runs:
7779
EXISTING_TAG=$(echo "$EXISTING_RELEASE" | jq -r '.tag_name')
7880
EXISTING_URL=$(echo "$EXISTING_RELEASE" | jq -r '.html_url')
7981
EXISTING_ID=$(echo "$EXISTING_RELEASE" | jq -r '.id')
80-
81-
if [[ "${{ inputs.draft }}" == "true" ]]; then
82+
83+
if [[ "$DRAFT_MODE" == "true" ]]; then
8284
# If draft=true and release exists, log warning and do nothing
8385
echo "::warning::A release with title '$EXPECTED_TITLE' already exists. Skipping creation since draft=true."
8486
echo "release-url=${EXISTING_URL}" >> $GITHUB_OUTPUT
@@ -102,7 +104,7 @@ runs:
102104
103105
# No existing release found, proceed with normal creation
104106
DRAFT_FLAG=""
105-
if [[ "${{ inputs.draft }}" == "true" ]]; then
107+
if [[ "$DRAFT_MODE" == "true" ]]; then
106108
DRAFT_FLAG="--draft"
107109
fi
108110
@@ -113,15 +115,15 @@ runs:
113115
fi
114116
115117
RELEASE_URL=$(gh release create "$VALIDATED_VERSION" \
116-
--target "${{ inputs.branch }}" \
118+
--target "$BRANCH_NAME" \
117119
--title "$VALIDATED_VERSION" \
118120
$NOTES_FLAG \
119121
$DRAFT_FLAG)
120122
121123
echo "release-url=${RELEASE_URL}" >> $GITHUB_OUTPUT
122124
123125
# Get the release ID only for published releases
124-
if [[ "${{ inputs.draft }}" != "true" ]]; then
126+
if [[ "$DRAFT_MODE" != "true" ]]; then
125127
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/$VALIDATED_VERSION --jq '.id')
126128
echo "release-id=${RELEASE_ID}" >> $GITHUB_OUTPUT
127129
fi
@@ -131,32 +133,35 @@ runs:
131133
env:
132134
GITHUB_TOKEN: ${{ inputs.github-token }}
133135
GITHUB_REF: ${{ inputs.branch }}
136+
DRAFT_MODE: ${{ inputs.draft }}
137+
RELEASE_WORKFLOW: ${{ inputs.release-workflow }}
138+
RELEASE_ID_OUTPUT: ${{ steps.create-release.outputs.release-id }}
134139
run: |
135140
# Set release ID based on draft status
136-
if [[ "${{ inputs.draft }}" == "true" ]]; then
141+
if [[ "$DRAFT_MODE" == "true" ]]; then
137142
RELEASE_ID_VALUE="N/A"
138143
else
139-
RELEASE_ID_VALUE="${{ steps.create-release.outputs.release-id }}"
144+
RELEASE_ID_VALUE="$RELEASE_ID_OUTPUT"
140145
fi
141-
142-
echo "Triggering release workflow '${{ inputs.release-workflow }}' with tag '$VALIDATED_VERSION', release ID '$RELEASE_ID_VALUE', and dryRun=${{ inputs.draft }}..."
143-
146+
147+
echo "Triggering release workflow '$RELEASE_WORKFLOW' with tag '$VALIDATED_VERSION', release ID '$RELEASE_ID_VALUE', and dryRun=$DRAFT_MODE..."
148+
144149
# Trigger the workflow
145-
gh workflow run "${{ inputs.release-workflow }}" \
150+
gh workflow run "$RELEASE_WORKFLOW" \
146151
--repo "${{ github.repository }}" \
147152
--ref $GITHUB_REF \
148153
-f "version=$VALIDATED_VERSION" \
149154
-f "releaseId=$RELEASE_ID_VALUE" \
150-
-f "dryRun=${{ inputs.draft }}"
151-
155+
-f "dryRun=$DRAFT_MODE"
156+
152157
echo "Workflow triggered successfully"
153-
158+
154159
# Wait a moment for the workflow to start, then get the run ID
155160
sleep 30
156-
161+
157162
RUN_ID=$(gh run list \
158163
--repo "${{ github.repository }}" \
159-
--workflow "${{ inputs.release-workflow }}" \
164+
--workflow "$RELEASE_WORKFLOW" \
160165
--limit 1 \
161166
--created ">=$(date -u -d '5 minutes ago' +%Y-%m-%dT%H:%M:%SZ)" \
162167
--json databaseId \

0 commit comments

Comments
 (0)