generate-versions-file #1673
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: generate-versions-file | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.17 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
with: | |
repository: xabot/gowrap | |
token: ${{ secrets.BOT_GITHUB_TOKEN }} | |
- name: Fetch latest code | |
run: | | |
git remote add upstream https://github.com/$GITHUB_REPOSITORY | |
git fetch upstream master | |
git rebase upstream/master | |
git push origin master | |
- name: Generate versions file | |
run: | | |
make generate-versions-file | |
git diff | |
- id: check-versions-file | |
name: Check if changes in versions file | |
run: git diff-index --exit-code HEAD data/versions.json | |
continue-on-error: true | |
- name: Install hub | |
run: sudo apt-get update && sudo apt-get install -y hub | |
if: "steps.check-versions-file.outcome == 'failure'" | |
- name: Publish changes | |
run: | | |
set -eu | |
git config --local user.email "[email protected]" | |
git config --local user.name "xabot" | |
BRANCH_NAME=new-versions-$(date +%F) | |
git checkout -b $BRANCH_NAME | |
git add data/versions.json | |
git commit -m "new versions file $(date +%F) [skip changelog]" | |
hub pull-request -p --no-edit --labels versions --head xabot:$BRANCH_NAME --base xabierlaiseca:master --no-maintainer-edits | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} | |
if: "steps.check-versions-file.outcome == 'failure'" | |
- name: Merge PR | |
run: | | |
set -eu | |
PR_NUMBER=$(hub pr show -f %I) | |
set +e | |
hub ci-status #$PR_NUMBER 1>/dev/null | |
CI_STATUS=$? | |
while [ $CI_STATUS -gt 1 ]; do | |
sleep 5 | |
hub ci-status #$PR_NUMBER 1>/dev/null | |
CI_STATUS=$? | |
done | |
set -e | |
if [ $CI_STATUS -ne 0 ]; then | |
exit $CI_STATUS | |
fi | |
hub api -XPUT --field merge_method=rebase "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/merge" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: "steps.check-versions-file.outcome == 'failure'" |