chore: Updating Python Requirements (#816) #144
Workflow file for this run
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
name: Create credentials PR for version bump | |
# This workflow is triggered when a commit is tagged. | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
create_pr: | |
name: CreatePR | |
runs-on: ubuntu-latest | |
if: ${{contains(github.ref, 'tags')}} | |
steps: | |
# Clone edx/credentials | |
- name: clone credentials | |
uses: actions/checkout@v4 | |
with: | |
repository: 'edx/credentials' | |
token: ${{ secrets.REQUIREMENTS_BOT_GITHUB_TOKEN }} | |
# Create branch with new version and push | |
- name: update version in branch | |
run: | | |
git checkout -b edx-deployment/credentials-themes/$GITHUB_SHA | |
git config user.email "edx-deployment@edx.org" | |
git config user.name "Edx Deployment automation robot" | |
RELEASE_TAG=${GITHUB_REF#refs/tags/} | |
sed -i -e "s|credentials-themes.git@.*|credentials-themes.git@$RELEASE_TAG#egg=edx_credentials_themes==$RELEASE_TAG|" requirements/base.in | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
architecture: x64 | |
- name: upgrade requirements | |
run: make upgrade | |
- name: commit and push upgrades | |
run: | | |
git add requirements/ | |
RELEASE_TAG=${GITHUB_REF#refs/tags/} | |
git commit -m "chore: bump credentials-themes to $RELEASE_TAG" | |
git push --set-upstream origin edx-deployment/credentials-themes/$GITHUB_SHA | |
# Create a PR and comment on original PR | |
- name: create PR | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.REQUIREMENTS_BOT_GITHUB_TOKEN}} | |
script: | | |
// Create credentials PR from version-updating branch above | |
const createResponse = await github.rest.pulls.create({ | |
title: 'chore: bump credentials-themes version', | |
owner: 'edx', | |
repo: 'credentials', | |
head: 'edx-deployment/credentials-themes/' + context.sha, | |
base: 'master', | |
}) | |
// Get the PR that relates to the tagged commit | |
const getRelatedPrResponse = await github.rest.repos.listPullRequestsAssociatedWithCommit({ | |
owner: 'edx', | |
repo: 'credentials-themes', | |
commit_sha: process.env.GITHUB_SHA | |
}) | |
const prNumber = getRelatedPrResponse.data.length > 0 ? getRelatedPrResponse.data[0].number : undefined; | |
if (prNumber === undefined) { | |
console.log("No matching PR number for commit") | |
exit(1) | |
} | |
// Comment on the original PR with a link to the credentials PR | |
github.rest.issues.createComment({ | |
owner: 'edx', | |
repo: 'credentials-themes', | |
issue_number: prNumber, | |
body: `A PR has been created in the credentials repo to release this new version. Please review it here: ${createResponse.data.html_url}`, | |
}); |