-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding workflow to update changelog (#32)
* adding workflow to update changelog * change event type * update workflow * fix formats
- Loading branch information
Showing
3 changed files
with
173 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Make pull request | ||
description: Create commit and make pull-request | ||
inputs: | ||
commit-files: | ||
description: "Which files will add to commit" | ||
required: true | ||
commit-message: | ||
description: "Message for creating a commit" | ||
required: true | ||
app-id: | ||
description: "Id for getting access to GitHub app" | ||
required: true | ||
app-token: | ||
description: "Token for getting access to GitHub app" | ||
required: true | ||
branch-name: | ||
description: "Name for branch for creating a commit" | ||
required: true | ||
pr-base: | ||
description: "Base branch for creating PR" | ||
required: true | ||
pr-title: | ||
description: "Title for creating Pull Request" | ||
required: true | ||
pr-body: | ||
description: "Body for creating Pull Request" | ||
required: true | ||
pr-reviewer: | ||
description: "Reviewers for creating PR, support comma delimiter" | ||
required: false | ||
default: "stepanLav,leohar" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: tibdex/github-app-token@v1 | ||
id: generate-token | ||
with: | ||
app_id: ${{ inputs.app-id }} | ||
private_key: ${{ inputs.app-token }} | ||
|
||
- name: Create Pull Request | ||
id: create_pr | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ steps.generate-token.outputs.token }} | ||
commit-message: ${{ inputs.commit-message }} | ||
add-paths: ${{ inputs.commit-files }} | ||
committer: novasama-bot <140433189+novasama-bot[bot]@users.noreply.github.com> | ||
author: novasama-bot <140433189+novasama-bot[bot]@users.noreply.github.com> | ||
signoff: false | ||
branch: ${{ inputs.branch-name }} | ||
delete-branch: true | ||
title: ${{ inputs.pr-title }} | ||
body: ${{ inputs.pr-body }} | ||
reviewers: ${{ inputs.pr-reviewer }} | ||
draft: false | ||
base: ${{ inputs.pr-base }} | ||
|
||
outputs: | ||
pull-request-url: ${{ steps.create_pr.outputs.pull-request-url }} |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Update changelog | ||
|
||
on: | ||
repository_dispatch: | ||
types: [create-pr] | ||
|
||
env: | ||
PR_REVIEWER: ERussel,leohar,valentunn,stepanLav | ||
|
||
jobs: | ||
create-pr-to-update: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
pr-url: ${{ steps.pr.outputs.pull-request-url }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Payload extraction | ||
id: payload | ||
run: | | ||
echo "VERSION=${{ fromJSON(github.event.client_payload).version }}" >> $GITHUB_ENV | ||
echo "COMMENT_LINK=${{ fromJSON(github.event.client_payload).comment_link }}" >> $GITHUB_ENV | ||
echo "TIME=${{ fromJSON(github.event.client_payload).time }}" >> $GITHUB_ENV | ||
echo "SEVERITY=${{ fromJSON(github.event.client_payload).severity }}" >> $GITHUB_ENV | ||
- name: Fetch comment body and save to file | ||
run: | | ||
COMMENT_BODY=$(curl -s "${{ steps.payload.outputs.COMMENT_LINK }}") | ||
echo "$COMMENT_BODY" > updates/changelogs/release/${{ steps.payload.outputs.VERSION }}.md | ||
- name: Update entrypoint_release | ||
run: python scripts/version_updater.py ${{ steps.payload.outputs.VERSION }} ${{ steps.payload.outputs.TIME }} ${{ steps.payload.outputs.SEVERITY }} | ||
|
||
- name: Make Pull Request | ||
id: pr | ||
uses: ./.github/workflows/make-pull-request | ||
with: | ||
commit-files: ./ | ||
commit-message: Create release notes for ${{ steps.payload.outputs.VERSION }} | ||
app-id: ${{ secrets.PR_APP_ID}} | ||
app-token: ${{ secrets.PR_APP_TOKEN}} | ||
pr-reviewer: ${{ env.PR_REVIEWER }} | ||
branch-name: release-notes-${{ steps.payload.outputs.VERSION }} | ||
pr-title: 🚀 Release notes for ${{ steps.payload.outputs.VERSION }} | ||
pr-body: This PR was generated automatically 🤖 | ||
pr-base: master | ||
|
||
alert: | ||
runs-on: ubuntu-latest | ||
needs: [create-pr-to-update] | ||
if: always() | ||
env: | ||
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
steps: | ||
- name: Report | ||
uses: appleboy/telegram-action@master | ||
with: | ||
to: ${{ secrets.TELEGRAM_TO }} | ||
token: ${{ secrets.TELEGRAM_TOKEN }} | ||
message: | | ||
🚀 New Android release notes have been created, please check them out: | ||
PR: | ||
${{ needs.create-pr-to-update.outputs.pr-url }} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
This script updates a JSON file with a new payload or updates an existing one based on the version. | ||
Usage: | ||
python version_updater.py <version> <time> <severity> | ||
Example: | ||
python version_updater.py 6.7.1 2023-07-26T15:00:00Z Major | ||
""" | ||
|
||
import argparse | ||
import json | ||
|
||
RELEASE_FILE_PATH = 'updates/v1/entrypoint_release.json' | ||
|
||
def update_json(version, time, severity): | ||
# Load the existing data | ||
with open(RELEASE_FILE_PATH, 'r') as f: | ||
data = json.load(f) | ||
|
||
# Create the new payload | ||
payload = {'version': version, 'time': time, 'severity': severity} | ||
|
||
# Check if the version already exists in the data | ||
for item in data: | ||
if item['version'] == version: | ||
# Update the existing entry | ||
item['time'] = time | ||
item['severity'] = severity | ||
break | ||
else: | ||
# Add the new payload if the version was not found | ||
data.append(payload) | ||
|
||
# Save the updated data | ||
with open(RELEASE_FILE_PATH, 'w') as f: | ||
json.dump(data, f, indent=4) | ||
f.write('\n') | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("version") | ||
parser.add_argument("time") | ||
parser.add_argument("severity") | ||
args = parser.parse_args() | ||
|
||
update_json(args.version, args.time, args.severity) |