diff --git a/.github/workflows/update-dmd-rewrite.yml b/.github/workflows/update-dmd-rewrite.yml new file mode 100644 index 0000000000..a36b7b5c69 --- /dev/null +++ b/.github/workflows/update-dmd-rewrite.yml @@ -0,0 +1,29 @@ +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions + +name: Update DMD rewrite +on: + schedule: + - cron: "0 0 * * *" # run every day at 00:00 + workflow_dispatch: # enable manual runs + +permissions: + contents: write + +jobs: + update-dmd-rewrite: + name: Update DMD rewrite + if: github.repository == 'ldc-developers/ldc' # don't run for forks + runs-on: ubuntu-22.04 + timeout-minutes: 20 + steps: + - uses: actions/checkout@v6 + with: + submodules: false + - name: Install git-filter-repo v2.34.0 + run: | + set -eux + sudo apt-get -q update + sudo apt-get install -yq git-filter-repo + - run: tools/update-dmd-rewrite.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/tools/update-dmd-rewrite.sh b/tools/update-dmd-rewrite.sh index 457a22e4ad..1685e6a932 100755 --- a/tools/update-dmd-rewrite.sh +++ b/tools/update-dmd-rewrite.sh @@ -31,7 +31,7 @@ This reverts commit 4b76bfcb2eb24bb8786bd293201a5711fbf747fe==>This reverts comm EOF # clone DMD monorepo -git clone git@github.com:dlang/dmd.git dmd.tmp +git clone https://github.com/dlang/dmd.git dmd.tmp cd dmd.tmp # only for initialization: @@ -86,7 +86,11 @@ git branch --no-track "${refs_prefix}master" master git branch --no-track "${refs_prefix}stable" stable # add LDC repo as `ldc` remote -git remote add ldc git@github.com:ldc-developers/ldc.git +if [[ -v GITHUB_TOKEN ]]; then + git remote add ldc https://git:${GITHUB_TOKEN}@github.com/ldc-developers/ldc.git +else + git remote add ldc git@github.com:ldc-developers/ldc.git +fi # check for newly added DMD source files if [[ "$initialize" != 1 ]]; then