here's a test issue #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Discourse Update | |
on: | |
issues: | |
types: [opened, edited] | |
jobs: | |
update_discourse: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Get Issue Details | |
id: issue_details | |
run: | | |
echo "title=${{ github.event.issue.title }}" >> $GITHUB_ENV | |
echo "body=${{ github.event.issue.body }}" >> $GITHUB_ENV | |
echo "author=${{ github.event.issue.user.login }}" >> $GITHUB_ENV | |
echo "status=${{ github.event.issue.state }}" >> $GITHUB_ENV | |
- name: Fetch CSRF Token | |
id: csrf_token | |
run: | | |
CSRF_TOKEN=$(curl -s https://goodbids.discourse.group/session/csrf.json | jq -r .csrf) | |
echo "CSRF_TOKEN=${CSRF_TOKEN}" >> $GITHUB_ENV | |
- name: Encode JSON Payload | |
id: encode_json | |
run: | | |
ISSUE_TITLE="${{ env.title }}" | |
ISSUE_BODY="${{ env.body }}" | |
ISSUE_AUTHOR="${{ env.author }}" | |
ISSUE_STATUS="${{ env.status }}" | |
# Encode emojis in the JSON payload using jq and write to file | |
jq -n --arg title "$ISSUE_TITLE" --arg body "$ISSUE_BODY" --arg author "$ISSUE_AUTHOR" --arg status "$ISSUE_STATUS" '{title: $title, body: $body, author: $author, status: $status | tonumber}' > encoded.json | |
- name: Read Encoded JSON Payload | |
id: read_encoded_json | |
run: | | |
ENCODED_JSON=$(cat encoded.json) | |
echo "ENCODED_JSON=${ENCODED_JSON}" >> $GITHUB_ENV | |
- name: Post Update to Discourse | |
run: | | |
ENCODED_JSON="${{ env.ENCODED_JSON }}" | |
CSRF_TOKEN="${{ env.CSRF_TOKEN }}" | |
curl -X POST "https://goodbids.discourse.group/posts.json" \ | |
-H "Content-Type: application/json" \ | |
-H "Api-Key: ${{ secrets.DISCOURSE_UPDATE_SECRET }}" \ | |
-H "Api-Username: jaspercroome" \ | |
-H "X-CSRF-Token: $CSRF_TOKEN" \ | |
-d "${ENCODED_JSON}" |