Skip to content

Commit

Permalink
Uplift PR is created daily to uplift the submodule to the latest vers…
Browse files Browse the repository at this point in the history
…ion.

More details on exact behavior of these PR can be found here https://github.com/peter-evans/create-pull-request

The default behaviour of the action is to create a pull request that will be continually updated with new changes until it is merged or closed. Changes are committed and pushed to a fixed-name branch, the name of which can be configured with the branch input. Any subsequent changes will be committed to the same branch and reflected in the open pull request.

How the action behaves:

If there are changes (i.e. a diff exists with the checked-out base branch), the changes will be pushed to a new branch and a pull request created.
If there are no changes (i.e. no diff exists with the checked-out base branch), no pull request will be created and the action exits silently.
If a pull request already exists it will be updated if necessary. Local changes in the Actions workspace, or changes on the base branch, can cause an update. If no update is required the action exits silently.
If a pull request exists and new changes on the base branch make the pull request unnecessary (i.e. there is no longer a diff between the pull request branch and the base), the pull request is automatically closed. Additionally, if delete-branch is set to true the branch will be deleted.
  • Loading branch information
vmilosevic committed Sep 26, 2024
1 parent 198baac commit fc7f0c3
Showing 1 changed file with 43 additions and 35 deletions.
78 changes: 43 additions & 35 deletions .github/workflows/nightly-uplift.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,70 @@
# This workflow automates creation of uplift pull requests.
# Uplift PR is created daily to uplift the submodule to the latest version.

name: Nighty Uplift PR
name: Nighty Uplift

on:
schedule:
- cron: '0 0 * * *'
- cron: '0 8 * * *' # Runs at 08:00 UTC every day
workflow_dispatch: # Manual trigger
push:

jobs:
uplift-pr:
runs-on: ubuntu-latest
runs-on: ubuntu-latest

env:
SUBMODULE_PATH: third_party/tt-mlir
SUBMODULE_VERSION: origin/main

steps:

- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # Fetch all history and tags
ref: main

- name: Set env variable
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Create uplift PR
env:
GH_TOKEN: ${{ github.token }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
UPLIFT_BRANCH: uplift-${{ env.TODAY }}
SUBMODULE_PATH: third_party/tt-mlir
SUBMODULE_VERSION: origin/main
run: |
git config --global user.email ci@tenstorrent.com
git config --global user.name "Tenstorrent CI"
if git branch -a | grep -q "remotes/origin/uplift-"; then
echo "### Branch already exists on remote ###"
exit 0
fi
git checkout main
git checkout -b $UPLIFT_BRANCH
cd $SUBMODULE_PATH
git fetch origin
git checkout $SUBMODULE_VERSION
echo "### Latest commit in $SUBMODULE_PATH ###"
git log -1
cd ../..
if [ -z "$(git status --porcelain)" ]; then
echo "### No changes in $SUBMODULE_PATH ###"
exit 0
fi
echo "### Commit change and create PR ###"
git add $SUBMODULE_PATH
git commit -m "Uplift $SUBMODULE_PATH to $SUBMODULE_VERSION $TODAY"
git push origin $UPLIFT_BRANCH --force
gh pr create \
--title "Uplift $SUBMODULE_PATH to $SUBMODULE_VERSION $TODAY" \
--body "This PR uplifts the $SUBMODULE_PATH submodule to the $SUBMODULE_VERSION." \
--base main \
--head $UPLIFT_BRANCH \
--label uplift \
--reviewer ${{ vars.INTEGRATION_OWNER }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
id: create-pr
with:
branch: uplift
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
base: main
commit-message: "Uplift $SUBMODULE_PATH to $SUBMODULE_VERSION $TODAY"
title: "Uplift $SUBMODULE_PATH to $SUBMODULE_VERSION $TODAY"
body: "This PR uplifts the $SUBMODULE_PATH submodule to the $SUBMODULE_VERSION."
labels: uplift
reviewers: ${{ vars.INTEGRATION_OWNER }}
delete-branch: true
token: ${{ secrets.GH_TOKEN }}

- name: Approve Pull Request
if: ${{ steps.create-pr.outputs.pull-request-number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Pull Request Number - ${{ steps.create-pr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.create-pr.outputs.pull-request-url }}"
gh pr review ${{ steps.create-pr.outputs.pull-request-number }} --approve
- name: Enable Pull Request Automerge
if: ${{ steps.create-pr.outputs.pull-request-number }}
run: gh pr merge --merge --auto "${{ steps.create-pr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

0 comments on commit fc7f0c3

Please sign in to comment.