Skip to content

Sync Upstream

Sync Upstream #624

Workflow file for this run

name: Sync Upstream
on:
# FIXME: Running on push wouldn't make sense, would it?
# # Trigger upstream sync on push
# push:
# # Only when the following branches are pushed to
# branches:
# - 2.1.x
# - bugfix-2.1.x
# - skr-mini-e3-v3-0
# Trigger upstream sync on a schedule
schedule:
- cron: '0 6 * * *' # Once a day at 06:00
# Trigger upstream sync manually
workflow_dispatch:
jobs:
sync_main_branch:
name: Sync Upstream (2.1.x)
# FIXME: "env" is not available for job context
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
# if: ${{ env.ACT }} != 'true'
## TODO: Test running on self-hosted runners instead
runs-on: ubuntu-latest
# runs-on: self-hosted
# runs-on: [self-hosted, ubuntu-latest]
timeout-minutes: 15
steps:
# REQUIRED step
# Step 1: run a standard checkout action, provided by github
- name: Checkout target repo
uses: actions/checkout@v3
with:
# optional: set the branch to checkout,
# sync action checks out your 'target_sync_branch' anyway
# ref: skr-mini-e3-v3-0
ref: 2.1.x
# REQUIRED if your upstream repo is private (see wiki)
persist-credentials: false
# Speed up the cloning by reducing the depth
fetch-depth: 1
# Sync upstream repository
- name: Sync Upstream Repository
id: sync
# uses: ./.github/actions/sync-upstream
uses: Didstopia/Actions/sync-upstream@master
with:
upstream-repo: MarlinFirmware/Marlin
repo-token: ${{ secrets.GITHUB_TOKEN }}
# REQUIRED step
# Step 2: run the sync action
#- name: Sync upstream changes
# id: sync
# # uses: aormsby/Fork-Sync-With-Upstream-action@master
# uses: aormsby/[email protected]
# # uses: aormsby/[email protected]
# with:
# # Target branch in this repository
# target_sync_branch: 2.1.x
# # REQUIRED 'target_repo_token' exactly like this!
# # target_repo_token: ${{ secrets.GITHUB_TOKEN }}
# target_repo_token: ${{ secrets.GH_API_WORKFLOWS_TOKEN }}
# target_branch_push_args: '--force'
# # Upstream branch in another repository
# upstream_sync_branch: 2.1.x
# upstream_sync_repo: MarlinFirmware/Marlin
# # upstream_repo_access_token: ${{ secrets.UPSTREAM_REPO_SECRET }}
# # Overwrite and keep the upstream commits
# upstream_pull_args: '-s recursive -Xtheirs --allow-unrelated-histories'
#
# # Rebase instead of merge
# git_config_pull_rebase: true
#
# shallow_since: '2 days ago'
#
# # FIXME: Override test_mode when running locally with ACL
# # Set test_mode true to run tests instead of the true action!!
# test_mode: false
# Step 3: Display a sample message based on the sync output var 'has_new_commits'
- name: Build Trigger
if: steps.sync.outputs.synced == 'true'
run: |
echo "New commits were found and synced, triggering a new firmware build"
[ -z "${{ secrets.GITHUB_TOKEN }}" ] && echo "Skipping, no GITHUB_TOKEN" && exit 0
curl --request POST \
--url https://api.github.com/repos/Didstopia/Marlin/actions/workflows/build-btt-ender3v2.yaml/dispatches \
--header 'Content-Type: application/json' \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ secrets.GH_API_WORKFLOWS_TOKEN }}' \
--data '{
"ref": "skr-mini-e3-v3-0",
"inputs": {
"targetBranch": "2.1.x"
}
}'
# - name: No new commits
# if: steps.sync.outputs.synced == 'false'
# run: echo "There were no new commits."
# - name: Show value of 'synced'
# run: echo ${{ steps.sync.outputs.synced }}
sync_bugfix_branch:
## TODO: Test running on self-hosted runners instead
runs-on: ubuntu-latest
# runs-on: self-hosted
# runs-on: [self-hosted, ubuntu-latest]
name: Sync Upstream (bugfix-2.1.x)
timeout-minutes: 15
steps:
# REQUIRED step
# Step 1: run a standard checkout action, provided by github
- name: Checkout target repo
uses: actions/checkout@v3
with:
# optional: set the branch to checkout,
# sync action checks out your 'target_sync_branch' anyway
# ref: skr-mini-e3-v3-0
ref: bugfix-2.1.x
# REQUIRED if your upstream repo is private (see wiki)
persist-credentials: false
# Speed up the cloning by reducing the depth
fetch-depth: 1
# Sync upstream repository
- name: Sync Upstream Repository
id: sync
# uses: ./.github/actions/sync-upstream
uses: Didstopia/Actions/sync-upstream@master
with:
upstream-repo: MarlinFirmware/Marlin
repo-token: ${{ secrets.GITHUB_TOKEN }}
# REQUIRED step
# Step 2: run the sync action
#- name: Sync upstream changes
# id: sync
# # uses: aormsby/Fork-Sync-With-Upstream-action@master
# uses: aormsby/[email protected]
# # uses: aormsby/[email protected]
# with:
# # Target branch in this repository
# target_sync_branch: bugfix-2.1.x
# # REQUIRED 'target_repo_token' exactly like this!
# # target_repo_token: ${{ secrets.GITHUB_TOKEN }}
# target_repo_token: ${{ secrets.GH_API_WORKFLOWS_TOKEN }}
# # Upstream branch in another repository
# upstream_sync_branch: bugfix-2.1.x
# upstream_sync_repo: MarlinFirmware/Marlin
# # upstream_repo_access_token: ${{ secrets.UPSTREAM_REPO_SECRET }}
# # Overwrite and keep the upstream commits
# upstream_pull_args: '-s recursive -Xtheirs --allow-unrelated-histories'
#
# # Rebase instead of merge
# git_config_pull_rebase: true
#
# # FIXME: Override test_mode when running locally with ACL
# # Set test_mode true to run tests instead of the true action!!
# test_mode: false
# Step 3: Display a sample message based on the sync output var 'has_new_commits'
- name: Build Trigger
if: steps.sync.outputs.synced == 'true'
run: |
echo "New commits were found and synced, triggering a new firmware build"
[ -z "${{ secrets.GITHUB_TOKEN }}" ] && echo "Skipping, no GITHUB_TOKEN" && exit 0
curl --request POST \
--url https://api.github.com/repos/Didstopia/Marlin/actions/workflows/build-btt-ender3v2.yaml/dispatches \
--header 'Content-Type: application/json' \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ secrets.GH_API_WORKFLOWS_TOKEN }}' \
--data '{
"ref": "skr-mini-e3-v3-0",
"inputs": {
"targetBranch": "bugfix-2.1.x"
}
}'
# - name: No new commits
# if: steps.sync.outputs.synced == 'false'
# run: echo "There were no new commits."
# - name: Show value of 'synced'
# run: echo ${{ steps.sync.outputs.synced }}