Update releaser worflows #24
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: Update releaser worflows | |
on: | |
workflow_dispatch: | |
schedule: | |
# Monthly on the 23th | |
- cron: '0 2 23 * *' | |
jobs: | |
releaser_workflows: | |
name: Update releaser workflows | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- run: | | |
set -eux | |
wget -O prep-release.yml https://raw.githubusercontent.com/jupyter-server/jupyter_releaser/main/example-workflows/prep-release.yml | |
wget -O publish-release.yml https://raw.githubusercontent.com/jupyter-server/jupyter_releaser/main/example-workflows/publish-release.yml | |
working-directory: template/.github/workflows | |
- name: List files changed | |
id: files-changed | |
shell: bash -l {0} | |
run: | | |
set -ex | |
export CHANGES=$(git status --porcelain | tee /tmp/modified.log | wc -l) | |
cat /tmp/modified.log | |
echo "N_CHANGES=${CHANGES}" >> $GITHUB_OUTPUT | |
git diff | |
- name: Commit any changes | |
if: steps.files-changed.outputs.N_CHANGES != '0' | |
shell: bash -l {0} | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git pull --no-tags | |
export SHA=$(git rev-parse --short HEAD) | |
export BRANCH_NAME=new-releaser-workflows-${SHA} | |
git checkout -b "${BRANCH_NAME}" | |
# Needed for hub to create the pull request correctly | |
# Ref: https://github.com/github/hub/issues/1538 https://github.com/github/hub/pull/1705 | |
git remote set-head origin --auto | |
git add * | |
git commit -m "Automatic update of the releaser workflows" | |
git push --set-upstream origin "${BRANCH_NAME}" | |
gh pr create -B "main" -t "Updated releaser workflows available at ${SHA}" -b "Update releaser workflows from official GitHub repository" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |