Skip to content

AutoMerge - Nightly #553

AutoMerge - Nightly

AutoMerge - Nightly #553

Workflow file for this run

# This workflow is triggered by a cron job and merges the upstream 'devel' branch into 'devel+classic'.
# If there are merge conflicts, it creates an issue and does not push any changes.
# Incidentally, it also pushes 'upstream/devel:devel' to the repo, keeping our diff up-to-date.
#
# Changelog:
#
# In January 2023, ledgerwatch extracted a Go library from erigon called 'github.com/ledgerwatch/erigon-lib' as an external dependency.
# See github.com/etccooperative/erigon-lib for changes enabling Ethereum Classic support.
#
# This workflow attempts to manage the upstream merges of both github.com/etccooperative/erigon and github.com/etccooperative/erigon-lib.
# It will first fetch and merge github.com/ledgerwatch/erigon-lib into github.com/etccooperative/erigon-lib (branches: 'main' vs. 'main+classic').
# If this merge (and push to remote) is successful, it will then fetch, merge, and push github.com/ledgerwatch/erigon into github.com/etccooperative/erigon (branches: 'devel' vs. 'devel+classic').
name: AutoMerge - Nightly
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
erigon-lib:
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs
outputs:
ERIGON_LIB_HEAD: ${{ steps.merge.outputs.ERIGON_LIB_HEAD }}
steps:
- uses: actions/checkout@v3
with:
repository: etccooperative/erigon-lib
ref: main+classic
submodules: false
fetch-depth: 0
- name: Set up git config
run: |
git config --global user.email "b5c6@protonmail.com"
git config --global user.name "meowsbits"
# Keep forked remote default branch ('main') up-to-date with upstream.
- name: Push erigon-lib 'upstream/main:main' (with --force)
env:
MY_PAT: ${{ secrets.MEOWSBITS_REPOWORKFLOW_TOKEN }}
run: |
git remote add upstream https://github.com/ledgerwatch/erigon-lib.git
git fetch upstream
git remote set-url origin https://meowsbits:${MY_PAT}@github.com/etccooperative/erigon-lib.git
# 'Github Actions workflow push to another repo' @ https://stackoverflow.com/a/69979203
git config --unset-all http.https://github.com/.extraheader
git push origin upstream/main:main --force
# Keep forked remote ETC branch ('main+classic') merged with upstream's "main" branch.
- name: Merge erigon-lib branch 'main' into 'main+classic'
id: merge # Necessary for setting an OUTPUT value.
run: |
merge_status=$(git merge -X theirs upstream/main --no-edit)
if [[ $merge_status == 1 ]]; then
echo "Merge conflict detected"
exit 1
fi
# The merge was successful.
# Before exiting, save the newly-minted commit hash to an environment variable,
# which we'll reference later in an erigon update step upgrading (bumping) this dependency.
ERIGON_LIB_HEAD="$(git rev-parse HEAD)"
echo "ERIGON_LIB_HEAD=${ERIGON_LIB_HEAD}" # Debug print.
echo "ERIGON_LIB_HEAD=${ERIGON_LIB_HEAD}" >> $GITHUB_OUTPUT # Write the result to the special OUTPUT value.
exit 0
- name: Push erigon-lib changes if successful
if: success()
env:
MY_PAT: ${{ secrets.MEOWSBITS_REPOWORKFLOW_TOKEN }}
run: |
git remote set-url origin https://meowsbits:${MY_PAT}@github.com/etccooperative/erigon-lib.git
git push origin main+classic
- name: Create issue if failed
if: failure()
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/automerge-issue-on-failure.md
erigon:
needs: erigon-lib
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: devel+classic
submodules: false
fetch-depth: 0
token: ${{ secrets.MEOWSBITS_REPOWORKFLOW_TOKEN }}
- name: Set up git config
run: |
git config --global user.email "b5c6@protonmail.com"
git config --global user.name "meowsbits"
# Keep forked remote default branch ('devel') up-to-date with upstream.
- name: Push erigon 'upstream/devel:devel' (with --force)
env:
MY_PAT: ${{ secrets.MEOWSBITS_REPOWORKFLOW_TOKEN }}
run: |
git remote add upstream https://github.com/ledgerwatch/erigon.git
git fetch upstream
git remote set-url origin https://meowsbits:${MY_PAT}@github.com/${GITHUB_REPOSITORY}.git
git push origin upstream/devel:devel --force
# Update the erigon-lib dependency in go.mod.
# We use the environment variable ERIGON_LIB_HEAD, which was set in the previous step.
- uses: actions/setup-go@v3
with:
go-version: '1.20.0' # The Go version to download (if necessary) and use.
- name: Update erigon-lib dependency
run: |
echo "ERIGON_LIB_HEAD=${{ needs.erigon-lib.outputs.ERIGON_LIB_HEAD }}" # Debug print.
[[ -z "${{ needs.erigon-lib.outputs.ERIGON_LIB_HEAD }}" ]] && {
echo "ERIGON_LIB_HEAD is empty"
exit 0
}
go mod edit -replace "github.com/ledgerwatch/erigon-lib=github.com/etccooperative/erigon-lib@${{ needs.erigon-lib.outputs.ERIGON_LIB_HEAD }}"
go mod tidy
git diff --quiet || {
echo "Work tree has modified files."
git add go.mod go.sum
git commit -m "Update erigon-lib dependency"
}
# Keep forked remote ETC branch ('devel+classic') merged with upstream's "devel" branch.
- name: Merge erigon branch 'devel' into 'devel+classic'
run: |
merge_status=$(git merge -X theirs upstream/devel --no-edit)
if [[ $merge_status == 1 ]]; then
echo "Merge conflict detected"
exit 1
fi
exit 0
- name: Push erigon changes if successful
if: success()
env:
MY_PAT: ${{ secrets.MEOWSBITS_REPOWORKFLOW_TOKEN }}
run: |
git remote set-url origin https://meowsbits:${MY_PAT}@github.com/${GITHUB_REPOSITORY}.git
git push origin devel+classic
- name: Create issue if failed
if: failure()
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/automerge-issue-on-failure.md