Skip to content

Commit 4846c6a

Browse files
authored
ci(ci.yml,release.yml): removes the need for 3rd party actions (#2018)
* ci(ci.yml,release.yml): removes the need for 3rd party actions This will stop the need to use `sarisia/actions-status-discord` & `technote-space/workflow-conclusion-action` * revert(ci.yml): added the logic back to the if condition
1 parent 1213a1d commit 4846c6a

File tree

2 files changed

+62
-33
lines changed

2 files changed

+62
-33
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,36 @@ jobs:
173173
if: always() && github.event_name != 'pull_request' && !contains(github.event.head_commit.message, '[skip ci]')
174174
runs-on: ubuntu-24.04
175175
steps:
176-
- name: Combine Job Status
176+
- name: Determine Workflow Status
177177
id: status
178178
run: |
179-
failures=(neutral, skipped, timed_out, action_required)
180-
if [[ ${array[@]} =~ ${{ needs.publish.result }} ]]; then
181-
echo "status=failure" >> $GITHUB_OUTPUT
182-
else
183-
echo "status=${{ needs.publish.result }}" >> $GITHUB_OUTPUT
184-
fi
185-
186-
- name: Post Status to Discord
187-
uses: sarisia/actions-status-discord@58667542682a27f270460405363e3a982f57a7ee # v1.0.0
188-
with:
189-
webhook: ${{ secrets.DISCORD_WEBHOOK }}
190-
status: ${{ steps.status.outputs.status }}
191-
title: ${{ github.workflow }}
192-
nofail: true
179+
case "${{ needs.publish.result }}" in
180+
success) echo "status=Success" >> $GITHUB_OUTPUT; echo "colour=3066993" >> $GITHUB_OUTPUT ;;
181+
failure) echo "status=Failure" >> $GITHUB_OUTPUT; echo "colour=15158332" >> $GITHUB_OUTPUT ;;
182+
cancelled) echo "status=Cancelled" >> $GITHUB_OUTPUT; echo "colour=10181046" >> $GITHUB_OUTPUT ;;
183+
*) echo "status=Skipped" >> $GITHUB_OUTPUT; echo "colour=9807270" >> $GITHUB_OUTPUT ;;
184+
esac
185+
186+
- name: Send Discord notification
187+
shell: bash
188+
run: |
189+
WEBHOOK="${{ secrets.DISCORD_WEBHOOK }}"
190+
191+
PAYLOAD=$(cat <<EOF
192+
{
193+
"embeds": [{
194+
"title": "${{ steps.status.outputs.status }}: ${{ github.workflow }}",
195+
"color": ${{ steps.status.outputs.colour }},
196+
"fields": [
197+
{ "name": "Repository", "value": "[${{ github.repository }}](${{ github.server_url }}/${{ github.repository }})", "inline": true },
198+
{ "name": "Ref", "value": "${{ github.ref }}", "inline": true },
199+
{ "name": "Event", "value": "${{ github.event_name }}", "inline": true },
200+
{ "name": "Triggered by", "value": "${{ github.actor }}", "inline": true },
201+
{ "name": "Workflow", "value": "[${{ github.workflow }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})", "inline": true }
202+
],
203+
}]
204+
}
205+
EOF
206+
)
207+
208+
curl -sS -H "Content-Type: application/json" -X POST -d "$PAYLOAD" "$WEBHOOK" || true

.github/workflows/release.yml

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,36 @@ jobs:
191191
if: always()
192192
runs-on: ubuntu-24.04
193193
steps:
194-
- name: Get Build Job Status
195-
uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 # v3.0.3
196-
197-
- name: Combine Job Status
194+
- name: Determine Workflow Status
198195
id: status
199196
run: |
200-
failures=(neutral, skipped, timed_out, action_required)
201-
if [[ ${array[@]} =~ $WORKFLOW_CONCLUSION ]]; then
202-
echo "status=failure" >> $GITHUB_OUTPUT
203-
else
204-
echo "status=$WORKFLOW_CONCLUSION" >> $GITHUB_OUTPUT
205-
fi
206-
207-
- name: Post Status to Discord
208-
uses: sarisia/actions-status-discord@58667542682a27f270460405363e3a982f57a7ee # v1.0.0
209-
with:
210-
webhook: ${{ secrets.DISCORD_WEBHOOK }}
211-
status: ${{ steps.status.outputs.status }}
212-
title: ${{ github.workflow }}
213-
nofail: true
197+
case "${{ needs.publish.result }}" in
198+
success) echo "status=Success" >> $GITHUB_OUTPUT; echo "colour=3066993" >> $GITHUB_OUTPUT ;;
199+
failure) echo "status=Failure" >> $GITHUB_OUTPUT; echo "colour=15158332" >> $GITHUB_OUTPUT ;;
200+
cancelled) echo "status=Cancelled" >> $GITHUB_OUTPUT; echo "colour=10181046" >> $GITHUB_OUTPUT ;;
201+
*) echo "status=Skipped" >> $GITHUB_OUTPUT; echo "colour=9807270" >> $GITHUB_OUTPUT ;;
202+
esac
203+
204+
- name: Send Discord notification
205+
shell: bash
206+
run: |
207+
WEBHOOK="${{ secrets.DISCORD_WEBHOOK }}"
208+
209+
PAYLOAD=$(cat <<EOF
210+
{
211+
"embeds": [{
212+
"title": "${{ steps.status.outputs.status }}: ${{ github.workflow }}",
213+
"color": ${{ steps.status.outputs.colour }},
214+
"fields": [
215+
{ "name": "Repository", "value": "[${{ github.repository }}](${{ github.server_url }}/${{ github.repository }})", "inline": true },
216+
{ "name": "Ref", "value": "${{ github.ref }}", "inline": true },
217+
{ "name": "Event", "value": "${{ github.event_name }}", "inline": true },
218+
{ "name": "Triggered by", "value": "${{ github.actor }}", "inline": true },
219+
{ "name": "Workflow", "value": "[${{ github.workflow }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})", "inline": true }
220+
],
221+
}]
222+
}
223+
EOF
224+
)
225+
226+
curl -sS -H "Content-Type: application/json" -X POST -d "$PAYLOAD" "$WEBHOOK" || true

0 commit comments

Comments
 (0)