Notify Other Repositories On Release Actions Demo
This repository demonstrates the concept of notifying other repositories when a release is made in this repository.
The workflow showcased runs a python script, .allspice/utils/entrypoint.py
, which performs the notification task.
A text file with a list of repository URLs to notify is required, and the above script expects the list of repos file to be passed in as a command line argument. E.g.
https://hub.allspice.io/Actions-Examples/ReleaseNotifiableRepo.git
https://hub.allsipce.io/...
The notification is made through an issue created in each of the repositories to notify, with the title of the release in the issue title, and the body of the release in the issue's comment body.
Usage
Step 1) Generate a personal access token
This add-on requires a personal access token stored as Actions secret. Refer to the knowledge base article on Actions secrets to learn how to add the required secret to your repository.
In this example the personal access token is stored as PAT and passed as input to the action as demonstrated below:
Step 2) Add the following step to your actions:
# Create a new issue inside a target repository in AllSpice
name: Notify Remote Repositores About a Release
on:
release:
types: [published, edited, deleted]
jobs:
create-new-issue-in-remote-repo:
runs-on: ubuntu-latest
steps:
# Check out repository code
- name: "[📚->🖥️] Check out repository code"
uses: actions/checkout@v3
# Installs python requirements from the requirements.txt file
- name: "[🤼->🖥️] Install python requirements"
run: pip install -r .allspice/utils/requirements.txt
# Create a new issue in target repos
- name: Create a new issue in repos to notify about release
run: |
ALLSPICE_AUTH_TOKEN=${{ secrets.PAT }} \
python .allspice/utils/entrypoint.py \
"${{ allspice.repository }}" \
"${{ allspice.event.action }}" \
"${{ allspice.event.release.tag_name }}" \
"${{ allspice.event.release.name }}" \
"${{ allspice.event.release.html_url }}" \
"${{ allspice.event.release.body }}" \
.allspice/notify_repos.txt \
--allspice_hub_url "${{ allspice.server_url }}"
Step 3) Create a release
Create a release in this repository to kick off the action that notifies the repositories listed in the text file passed to the script.
Step 4) Inspect issues in notifiable repositories for release notifications
Confirm in the repositories to be notified that issues were created for the release notification.