Merge upstream main #20
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: Merge upstream main | |
on: | |
schedule: | |
- cron: '0 06,12 * * *' | |
workflow_dispatch: | |
jobs: | |
merge: | |
if: github.repository_owner == 'akerbp-dataops' | |
runs-on: ubuntu-latest | |
outputs: | |
merge_occurred: ${{ steps.merge.outputs.merge_occurred }} | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- name: Merge upstream | |
id: merge | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git pull --unshallow | |
git remote add upstream https://github.com/equinor/witsml-explorer.git | |
git fetch upstream main | |
git checkout main | |
if test $(git rev-list --left-right --count main...upstream/main | cut -f2) -gt 0; then | |
git merge --no-edit upstream/main | |
git push origin main | |
echo "merge_occurred=true" >> $GITHUB_OUTPUT | |
else | |
echo "merge_occurred=false" >> $GITHUB_OUTPUT | |
fi | |
notify: | |
if: github.repository_owner == 'akerbp-dataops' && needs.merge.outputs.merge_occurred == 'true' | |
runs-on: ubuntu-latest | |
needs: [merge] | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- name: Create repository dispatch event | |
run: | | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.DISPATCH_TOKEN }}"\ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/akerbp-dataops/witsml-explorer-cicd/dispatches \ | |
-d '{"event_type":"mergedispatch ${{ github.ref_name }}","client_payload":{"branch": "${{ github.ref_name }}", "version":"latest"}}' |