Skip to content

Commit

Permalink
Merge pull request akto-api-security#389 from akto-api-security/beame…
Browse files Browse the repository at this point in the history
…r_workflow_yml

modify beamer workflow yml
  • Loading branch information
ankush-jain-akto committed Jun 28, 2023
2 parents 9cb1573 + 435a55c commit 1195055
Showing 1 changed file with 59 additions and 19 deletions.
78 changes: 59 additions & 19 deletions .github/workflows/beamer.yml
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

0 comments on commit 1195055

Please sign in to comment.