Skip to content

Commit

Permalink
Update Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
I-am-PUID-0 committed Jun 25, 2024
1 parent 8e1b109 commit 661c6a6
Showing 1 changed file with 1 addition and 61 deletions.
62 changes: 1 addition & 61 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ env.REPO_NAME }}:${{ env.VERSION }}
Expand Down Expand Up @@ -97,66 +97,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Post announcement to Discussions
id: post_announcement
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.build-and-push.outputs.version }}
run: |
echo "Fetching discussion categories..."
RESPONSE=$(gh api -H "Authorization: token $GITHUB_TOKEN" /repos/${{ github.repository }}/discussions/categories 2>&1)
echo "Response: $RESPONSE"
if [[ $? -ne 0 ]]; then
echo "Error: Unable to fetch discussion categories"
exit 1
fi
DISCUSSION_CATEGORY_ID=$(echo "$RESPONSE" | jq -r '.[] | select(.slug=="announcements") | .id')
echo "DISCUSSION_CATEGORY_ID: $DISCUSSION_CATEGORY_ID"
if [[ -z "$DISCUSSION_CATEGORY_ID" ]]; then
echo "Error: Could not find Announcements category ID"
exit 1
fi
RELEASE_NOTES=$(awk '/^## Version \[${{ env.VERSION }}\]/ {flag=1; next} /^## Version \[/ {flag=0} flag' CHANGELOG.md)
ANNOUNCEMENT_BODY="🚀 **New Release: ${{ env.VERSION }}**\n\n${RELEASE_NOTES}\n\nDownload the release [here](https://github.com/${{ github.repository }}/releases/tag/${{ env.VERSION }})."
echo "Creating discussion post..."
RESPONSE=$(gh api -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" /repos/${{ github.repository }}/discussions -d "{\"title\":\"New Release: ${{ env.VERSION }}\",\"body\":\"${ANNOUNCEMENT_BODY}\",\"category_id\":\"$DISCUSSION_CATEGORY_ID\"}" 2>&1)
echo "Response: $RESPONSE"
if [[ $? -ne 0 ]]; then
echo "Error: Unable to create discussion post"
exit 1
fi
DISCUSSION_ID=$(echo "$RESPONSE" | jq -r '.id')
echo "DISCUSSION_ID: $DISCUSSION_ID"
if [[ -z "$DISCUSSION_ID" ]]; then
echo "Error: Could not create discussion"
exit 1
fi
echo "DISCUSSION_ID=$DISCUSSION_ID" >> $GITHUB_ENV
- name: Unpin previous announcements
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api -H "Authorization: token $GITHUB_TOKEN" /repos/${{ github.repository }}/discussions | jq -r '.[] | select(.category.slug=="announcements" and .is_pinned==true) | .node_id' | while read -r node_id; do
gh api -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" /repos/${{ github.repository }}/discussions/$node_id/unpin
done
- name: Pin new announcement
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" /repos/${{ github.repository }}/discussions/${{ env.DISCUSSION_ID }}/pin
- name: Post announcement to Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
Expand Down

0 comments on commit 661c6a6

Please sign in to comment.