Skip to content
name: Update version.json and create PR
on:
release:
types: [published]
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get release information
id: get_release
run: |
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest)
echo "$response" | jq '.tag_name, .name, .published_at, .body, .html_url' | tee /tmp/release_info
echo "::set-output name=tag_name::$(echo "$response" | jq -r .tag_name)"
echo "::set-output name=name::$(echo "$response" | jq -r .name)"
echo "::set-output name=published_at::$(echo "$response" | jq -r .published_at)"
echo "::set-output name=body::$(echo "$response" | jq -r .body)"
echo "::set-output name=html_url::$(echo "$response" | jq -r .html_url)"
- name: Update version.json
run: |
echo '{
"tag_name": "${{ steps.get_release.outputs.tag_name }}",
"release_name": "${{ steps.get_release.outputs.name }}",
"published_at": "${{ steps.get_release.outputs.published_at }}",
"body": "${{ steps.get_release.outputs.body }}"
"html_url": "${{ steps.get_release.outputs.html_url }}"
}' > version.json
- name: Create new branch
run: |
git checkout -b update-version-${{ steps.get_release.outputs.tag_name }}
git add version.json
git commit -m "Update version.json for release ${{ steps.get_release.outputs.tag_name }}"
- name: Push branch
run: |
git push origin update-version-${{ steps.get_release.outputs.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request
run: |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d '{
"title": "Update version.json for release ${{ steps.get_release.outputs.tag_name }}",
"body": "This PR updates version.json with the latest release information.",
"head": "update-version-${{ steps.get_release.outputs.tag_name }}",
"base": "develop"
}'