update-sources-main #207
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
# Generated by openshift-pipelines/hack. DO NOT EDIT. | |
name: update-sources-main | |
on: | |
workflow_dispatch: {} | |
schedule: | |
- cron: "30 */3 * * *" # At minute 30 past every 3rd hour. | |
jobs: | |
update-sources: | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout the current repo | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Clone tektoncd/cli | |
run: | | |
rm -fR upstream | |
git clone https://github.com/tektoncd/cli upstream | |
pushd upstream | |
git checkout -B main origin/main | |
popd | |
- name: Commit new changes | |
run: | | |
git config user.name openshift-pipelines-bot | |
git config user.email pipelines-extcomm@redhat.com | |
git checkout -b actions/update/sources-main | |
pushd upstream | |
OLD_COMMIT=$(cat ../head) | |
NEW_COMMIT=$(git rev-parse HEAD) | |
echo Previous commit: ${OLD_COMMIT} | |
git show --stat ${OLD_COMMIT} | |
echo New commit: ${NEW_COMMIT} | |
git show --stat ${NEW_COMMIT} | |
git diff --stat ${NEW_COMMIT}..${OLD_COMMIT} > /tmp/diff.txt | |
git rev-parse HEAD > ../head | |
popd | |
rm -rf upstream/.git | |
git add upstream head openshift | |
if [[ -z $(git status --porcelain --untracked-files=no) ]]; then | |
echo "No change, exiting" | |
exit 0 | |
fi | |
git commit -F- <<EOF | |
[bot] Update from tektoncd/cli to ${NEW_COMMIT} | |
$ git diff --stat ${NEW_COMMIT}..${OLD_COMMIT} | |
$(cat /tmp/diff.txt | sed 's/^/ /') | |
https://github.com/tektoncd/cli/compare/${NEW_COMMIT}..${OLD_COMMIT} | |
EOF | |
git push -f origin actions/update/sources-main | |
if [ "$(gh pr list --base main --head actions/update/sources-main --json url --jq 'length')" = "0" ]; then | |
echo "creating PR..." | |
gh pr create -B main -H actions/update/sources-main --fill | |
else | |
echo "a PR already exists, skipping..." | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |