From 690acb45ff19fda20a67dd0e0a3ec4f868fa06ca Mon Sep 17 00:00:00 2001 From: Felix Erdmann Date: Fri, 20 Dec 2024 09:25:55 +0100 Subject: [PATCH] chore: update release body with arduino libraries --- .../release-arduino-lib-versions.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/release-arduino-lib-versions.yaml diff --git a/.github/workflows/release-arduino-lib-versions.yaml b/.github/workflows/release-arduino-lib-versions.yaml new file mode 100644 index 0000000..2a59c9b --- /dev/null +++ b/.github/workflows/release-arduino-lib-versions.yaml @@ -0,0 +1,49 @@ +name: Update Release Body + +on: + release: + types: [published] + +jobs: + update-release-body: + runs-on: ubuntu-latest + + steps: + # Checkout the repository + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install jq + run: sudo apt-get install jq + + - name: Build docker container + run: docker build -t sketches --no-cache . + + # Generate the libraries list + - name: Generate libraries list + id: generate_libraries_list + run: docker run sketches arduino-cli lib list --all > libraries.txt + + # Read generated content into a variable + - name: Read generated content + id: read_content + run: echo "content=$(cat libraries.txt)" >> $GITHUB_OUTPUT + + # Update the release body + - name: Update Release Body + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Fetch the release details + RELEASE_URL=$(jq -r '.release.url' "${GITHUB_EVENT_PATH}") + RELEASE_BODY=$(jq -r '.release.body' "${GITHUB_EVENT_PATH}") + + # Append the generated text with a heading + NEW_BODY="${RELEASE_BODY}\n\n## Libraries\n\n\`\`\`\n${{ steps.read_content.outputs.content }}\n\`\`\`" + + # Update the release body using GitHub API + curl -X PATCH \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "${RELEASE_URL}" \ + -d "{\"body\":\"${NEW_BODY}\"}"