Scheduled Merge Upstream #3312
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: Scheduled Merge Upstream | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '23 0/3 * * *' | |
jobs: | |
merge_upstream: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
fetch-depth: 0 | |
token: ${{ secrets.OTEL_DEMO_MERGE_SECRET }} | |
- name: fetch and push | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
UPSTREAM: https://github.com/open-telemetry/opentelemetry-demo | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
git remote add upstream "${UPSTREAM}" | |
# Get all recent branches and commits from the upstream | |
git fetch upstream main | |
git merge upstream/main --no-edit || { echo "Merge conflicts detected. Please resolve them manually."; exit 1; } | |
git push origin $(git branch --show-current) | |
notify-failure: | |
needs: [merge_upstream] | |
if: always() && needs.merge_upstream.result != 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get previous workflow status | |
uses: Mercymeilya/[email protected] | |
id: last_status | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Slack notification | |
if: success() && steps.last_status.outputs.last_status == 'success' | |
env: | |
SLACK_WEBHOOK: ${{ secrets.OTELSLACKCHANNELWEBHOOK }} | |
SLACK_UNFURL_LINKS: "true" | |
uses: AlexanderWert/[email protected] | |
with: | |
args: | | |
:wave: | |
Auto-merge of the <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|elastic/opentelemetry-demo> repository with the upstream failed! | |
Manual resolution of the merge conflicts is required! | |