forked from akto-api-security/akto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request akto-api-security#389 from akto-api-security/beame…
…r_workflow_yml modify beamer workflow yml
- Loading branch information
Showing
1 changed file
with
59 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,68 @@ | ||
name: Push Release Notes to Beamer | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch | ||
|
||
jobs: | ||
push-release-notes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Push Release Notes to Beamer | ||
run: | | ||
# Set up variables | ||
BEAMER_API_TOKEN="${{ secrets.BEAMER_API_KEY }}" | ||
RELEASE_TAG="${{ github.event.release.tag_name }}" | ||
RELEASE_NOTES="${{github.event.release.body}}" | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Push release notes to Beamer | ||
curl --request POST \ | ||
--url https://api.getbeamer.com/v0/posts \ | ||
--header "Content-Type: application/json" \ | ||
--header "Beamer-Api-Key: $BEAMER_API_TOKEN" \ | ||
--data "{ | ||
\"title\": [ \"New Release: $RELEASE_TAG\" ], | ||
\"content\": [ \"$RELEASE_NOTES\" ], | ||
\"category\": \"new\", | ||
\"publish\": true | ||
}" | ||
- name: Get Latest Release | ||
id: get_latest_release | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install requests | ||
python3 - <<EOF | ||
import os | ||
import requests | ||
github_token = os.getenv('GITHUB_TOKEN') | ||
repo_owner = 'solankirishav21' | ||
repo_name = 'published_test' | ||
headers = {'Authorization': f'Bearer {github_token}'} | ||
url = f'https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest' | ||
response = requests.get(url, headers=headers) | ||
data = response.json() | ||
tag_name = data.get('tag_name') | ||
description = data.get('body') | ||
description_lines = description.split('\\n') if description else [] | ||
print(f"::set-output name=tag_name::{tag_name}") | ||
print(f"::set-output name=description_lines::{description_lines}") | ||
EOF | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Print Tag Name and Description | ||
run: | | ||
echo "Tag Name: ${{ steps.get_latest_release.outputs.tag_name }}" | ||
echo "Description: |" | ||
for line in ${{ steps.get_latest_release.outputs.description_lines }}; do | ||
echo " $line" | ||
done | ||
- name: Push Release Notes to Beamer | ||
env: | ||
BEAMER_API_TOKEN: ${{ secrets.BEAMER_API_KEY }} | ||
RELEASE_TAG: ${{ steps.get_latest_release.outputs.tag_name }} | ||
RELEASE_NOTES: | | ||
${{ join(steps.get_latest_release.outputs.description_lines, '\n') }} | ||
run: | | ||
# Push release notes to Beamer | ||
IFS=$'\n' | ||
for line in $RELEASE_NOTES; do | ||
curl --request POST \ | ||
--url https://api.getbeamer.com/v0/posts \ | ||
--header "Content-Type: application/json" \ | ||
--header "Beamer-Api-Key: $BEAMER_API_TOKEN" \ | ||
--data "{ | ||
\"title\": [ \"New Release: $RELEASE_TAG\" ], | ||
\"content\": [ \"$line\" ], | ||
\"category\": \"new\", | ||
\"publish\": true | ||
}" | ||
done |