|
| 1 | +# Cre: https://github.com/orgs/community/discussions/153608#discussioncomment-12453674 |
| 2 | +name: Sync Fork with Upstream |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 0 * * *" # Runs daily at midnight UTC |
| 6 | + workflow_dispatch: # Allows manual triggering |
| 7 | + |
| 8 | +jobs: |
| 9 | + sync: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Configure Git |
| 13 | + run: | |
| 14 | + git config --global user.email "994931+Zarloc@users.noreply.github.com" |
| 15 | + git config --global user.name "Zarloc" |
| 16 | +
|
| 17 | + - name: Checkout Forked Repository |
| 18 | + uses: actions/checkout@v6 |
| 19 | + with: |
| 20 | + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Sync Upstream & Apply Patch |
| 24 | + run: | |
| 25 | + # 1. Store the workflow file content in an environment variable for later use |
| 26 | + # We need to do this before we reset the branch, otherwise the file will be lost and we won't be able to add it back in the commit |
| 27 | + export SYNC_UPSTREAM=$(cat .github/workflows/sync-upstream.yml) |
| 28 | + |
| 29 | + # 2. Fetch Upstream |
| 30 | + git remote add upstream https://github.com/netdata/netdata.git |
| 31 | + git fetch upstream master |
| 32 | +
|
| 33 | + # 3. Hard Reset: Wipe local history to match Upstream exactly |
| 34 | + # This removes yesterday's patch commit so we don't get conflicts |
| 35 | + git checkout master |
| 36 | + git reset --hard upstream/master |
| 37 | +
|
| 38 | + # 4. Apply the Hack (sed) |
| 39 | + echo "Applying auth bypass patch..." |
| 40 | + sed -i 's/return ((user & endpoint) == endpoint);/return true;/' src/web/api/http_auth.h |
| 41 | + |
| 42 | + # 5. Recreate the workflow file (because we reset the branch, we lost the file, so we need to add it back before committing) |
| 43 | + echo "Recreating workflow file..." |
| 44 | + echo "$SYNC_UPSTREAM" > .github/workflows/sync-upstream.yml |
| 45 | +
|
| 46 | + # 6. Commit the changes |
| 47 | + git add src/web/api/http_auth.h |
| 48 | + git add .github/workflows/sync-upstream.yml |
| 49 | + git commit -m "feat: bypass Netdata Cloud sign-in which is required to access dashboard features" |
| 50 | +
|
| 51 | + # 7. Force Push |
| 52 | + # We force push because we rewrote history (replaced yesterday's commit with today's) |
| 53 | + git push origin master --force |
0 commit comments