diff --git a/.github/workflows/handle-new-mails.yml b/.github/workflows/handle-new-mails.yml index 0332090..c37f2d9 100644 --- a/.github/workflows/handle-new-mails.yml +++ b/.github/workflows/handle-new-mails.yml @@ -10,31 +10,35 @@ concurrency: jobs: handle-new-mails: runs-on: ubuntu-latest + if: vars.CONFIG != '' steps: - uses: actions/create-github-app-token@v1 - id: gitgitgadget-git-token + id: pr-repo-token with: app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }} - owner: gitgitgadget - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.owner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: actions/create-github-app-token@v1 - id: git-git-token + if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.baseOwner) }} + id: upstream-repo-token with: app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }} - owner: git - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.baseOwner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: actions/create-github-app-token@v1 - id: dscho-git-token + if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.testOwner) }} + id: test-repo-token with: app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }} - owner: dscho - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.testOwner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: gitgitgadget/gitgitgadget/handle-new-mails@v1 with: - pr-repo-token: ${{ steps.gitgitgadget-git-token.outputs.token }} - upstream-repo-token: ${{ steps.git-git-token.outputs.token }} - test-repo-token: ${{ steps.dscho-git-token.outputs.token }} + config: ${{ vars.CONFIG }} + pr-repo-token: ${{ steps.pr-repo-token.outputs.token }} + upstream-repo-token: ${{ steps.upstream-repo-token.outputs.token }} + test-repo-token: ${{ steps.test-repo-token.outputs.token }} diff --git a/.github/workflows/handle-pr-comment.yml b/.github/workflows/handle-pr-comment.yml index 31e3cec..9d4fe6a 100644 --- a/.github/workflows/handle-pr-comment.yml +++ b/.github/workflows/handle-pr-comment.yml @@ -19,29 +19,32 @@ concurrency: jobs: handle-pr-comment: runs-on: ubuntu-latest + if: vars.CONFIG != '' steps: - uses: actions/create-github-app-token@v1 - id: gitgitgadget-git-token + id: pr-repo-token with: app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }} - owner: gitgitgadget - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.owner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: actions/create-github-app-token@v1 - id: git-git-token + if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.baseOwner) }} + id: upstream-repo-token with: app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }} - owner: git - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.baseOwner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: actions/create-github-app-token@v1 - id: dscho-git-token + if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.testOwner) }} + id: test-repo-token with: app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }} - owner: dscho - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.testOwner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - name: create a check run id: create-check-run run: | @@ -66,9 +69,9 @@ jobs: echo "repo=$repo" >> $GITHUB_OUTPUT export GH_TOKEN="$(case "$repo" in - gitgitgadget/git) echo "${{ steps.gitgitgadget-git-token.outputs.token }}";; - git/git) echo "${{ steps.git-git-token.outputs.token }}";; - dscho/git) echo "${{ steps.dscho-git-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.owner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.pr-repo-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.baseOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.upstream-repo-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.testOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.test-repo-token.outputs.token }}";; *) echo "${{ secrets.GITHUB_TOKEN }}";; esac )" @@ -84,20 +87,21 @@ jobs: echo "check_run_id=$check_run_id" >> $GITHUB_OUTPUT - uses: gitgitgadget/gitgitgadget/handle-pr-comment@v1 with: - pr-repo-token: ${{ steps.gitgitgadget-git-token.outputs.token }} - upstream-repo-token: ${{ steps.git-git-token.outputs.token }} - test-repo-token: ${{ steps.dscho-git-token.outputs.token }} - smtp-host: smtp.gmail.com - smtp-user: gitgitgadget@gmail.com + config: ${{ vars.CONFIG }} + pr-repo-token: ${{ steps.pr-repo-token.outputs.token }} + upstream-repo-token: ${{ steps.upstream-repo-token.outputs.token }} + test-repo-token: ${{ steps.test-repo-token.outputs.token }} + smtp-host: '${{ fromJSON(vars.CONFIG).mail.smtpHost }}' + smtp-user: '${{ fromJSON(vars.CONFIG).mail.smtpUser }}' smtp-pass: "${{ secrets.GITGITGADGET_SMTP_PASS }}" pr-comment-url: ${{ env.PR_COMMENT_URL }} - name: update the check run if: always() && steps.create-check-run.outputs.check_run_id != '' run: | export GH_TOKEN="$(case "${{ steps.create-check-run.outputs.repo }}" in - gitgitgadget/git) echo "${{ steps.gitgitgadget-git-token.outputs.token }}";; - git/git) echo "${{ steps.git-git-token.outputs.token }}";; - dscho/git) echo "${{ steps.dscho-git-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.owner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.pr-repo-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.baseOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.upstream-repo-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.testOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.test-repo-token.outputs.token }}";; *) echo "${{ secrets.GITHUB_TOKEN }}";; esac )" diff --git a/.github/workflows/handle-pr-push.yml b/.github/workflows/handle-pr-push.yml index 6ef1c96..4e78716 100644 --- a/.github/workflows/handle-pr-push.yml +++ b/.github/workflows/handle-pr-push.yml @@ -19,29 +19,32 @@ concurrency: jobs: handle-pr-push: runs-on: ubuntu-latest + if: vars.CONFIG != '' steps: - uses: actions/create-github-app-token@v1 - id: gitgitgadget-git-token + id: pr-repo-token with: app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }} - owner: gitgitgadget - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.owner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: actions/create-github-app-token@v1 - id: git-git-token + if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.baseOwner) }} + id: upstream-repo-token with: app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }} - owner: git - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.baseOwner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: actions/create-github-app-token@v1 - id: dscho-git-token + if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.testOwner) }} + id: test-repo-token with: app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }} - owner: dscho - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.testOwner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - name: create a check run id: create-check-run run: | @@ -64,9 +67,9 @@ jobs: echo "repo=$repo" >> $GITHUB_OUTPUT export GH_TOKEN="$(case "$repo" in - gitgitgadget/git) echo "${{ steps.gitgitgadget-git-token.outputs.token }}";; - git/git) echo "${{ steps.git-git-token.outputs.token }}";; - dscho/git) echo "${{ steps.dscho-git-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.owner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.pr-repo-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.baseOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.upstream-repo-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.testOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.test-repo-token.outputs.token }}";; *) echo "${{ secrets.GITHUB_TOKEN }}";; esac )" @@ -82,17 +85,18 @@ jobs: echo "check_run_id=$check_run_id" >> $GITHUB_OUTPUT - uses: gitgitgadget/gitgitgadget/handle-pr-push@v1 with: - pr-repo-token: ${{ steps.gitgitgadget-git-token.outputs.token }} - upstream-repo-token: ${{ steps.git-git-token.outputs.token }} - test-repo-token: ${{ steps.dscho-git-token.outputs.token }} + config: ${{ vars.CONFIG }} + pr-repo-token: ${{ steps.pr-repo-token.outputs.token }} + upstream-repo-token: ${{ steps.upstream-repo-token.outputs.token }} + test-repo-token: ${{ steps.test-repo-token.outputs.token }} pr-url: ${{ env.PR_URL }} - name: update the check run if: always() && steps.create-check-run.outputs.check_run_id != '' run: | export GH_TOKEN="$(case "${{ steps.create-check-run.outputs.repo }}" in - gitgitgadget/git) echo "${{ steps.gitgitgadget-git-token.outputs.token }}";; - git/git) echo "${{ steps.git-git-token.outputs.token }}";; - dscho/git) echo "${{ steps.dscho-git-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.owner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.pr-repo-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.baseOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.upstream-repo-token.outputs.token }}";; + '${{ fromJSON(vars.CONFIG).repo.testOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.test-repo-token.outputs.token }}";; *) echo "${{ secrets.GITHUB_TOKEN }}";; esac )" diff --git a/.github/workflows/initialize-git-notes.yml b/.github/workflows/initialize-git-notes.yml new file mode 100644 index 0000000..4e1715e --- /dev/null +++ b/.github/workflows/initialize-git-notes.yml @@ -0,0 +1,25 @@ +name: Initialize Git notes + +# This workflow is expected to be triggered manually, exactly once, when +# GitGitGadget is first used with a new `pr-repo`. + +on: + workflow_dispatch: + +jobs: + initialize-git-notes: + runs-on: ubuntu-latest + + steps: + - uses: actions/create-github-app-token@v1 + id: pr-repo-token + with: + app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }} + private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }} + owner: ${{ fromJSON(vars.CONFIG).repo.owner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} + - uses: gitgitgadget/gitgitgadget/initialize-git-notes@v1 + with: + config: ${{ vars.CONFIG }} + pr-repo-token: ${{ steps.pr-repo-token.outputs.token }} + initial-user: ${{ github.actor }} diff --git a/.github/workflows/sync-mailing-list-mirror.yml b/.github/workflows/sync-mailing-list-mirror.yml index b08b856..81c1d90 100644 --- a/.github/workflows/sync-mailing-list-mirror.yml +++ b/.github/workflows/sync-mailing-list-mirror.yml @@ -6,9 +6,9 @@ on: - cron: "*/5 * * * *" env: - LORE_EPOCH: 1 # also adjust SOURCE_REPOSITORY - SOURCE_REPOSITORY: https://lore.kernel.org/git/1 # LORE_EPOCH - TARGET_GITHUB_REPOSITORY: gitgitgadget/git-mailing-list-mirror + MIRROR_REF: ${{ fromJSON(vars.CONFIG).mailrepo.mirrorRef }} + SOURCE_REPOSITORY: ${{ fromJSON(vars.CONFIG).mailrepo.url }}${{ fromJSON(vars.CONFIG).mailrepo.public_inbox_epoch }} + TARGET_GITHUB_REPOSITORY: ${{ fromJSON(vars.CONFIG).mailrepo.owner }}/${{ fromJSON(vars.CONFIG).mailrepo.name }} concurrency: group: sync-mailing-list-mirror @@ -27,16 +27,16 @@ jobs: echo "org=${TARGET_GITHUB_REPOSITORY%%/*}" >>$GITHUB_OUTPUT && echo "repo=${TARGET_GITHUB_REPOSITORY#*/}" >>$GITHUB_OUTPUT && source="$(git ls-remote "$SOURCE_REPOSITORY" master)" && - target="$(git ls-remote https://github.com/"$TARGET_GITHUB_REPOSITORY" lore-$LORE_EPOCH)" && + target="$(git ls-remote https://github.com/"$TARGET_GITHUB_REPOSITORY" "$MIRROR_REF")" && echo "result=$(test "${source%% *}" = "${target%% *}" && echo false || echo true)" >>$GITHUB_OUTPUT - name: Partial clone if: steps.needs-update.outputs.result == 'true' run: | - git clone --bare --depth=1 -b lore-$LORE_EPOCH --filter=blob:none https://github.com/$TARGET_GITHUB_REPOSITORY . + git clone --bare --depth=1 -b "${MIRROR_REF#refs/heads/}" --filter=blob:none https://github.com/$TARGET_GITHUB_REPOSITORY . - name: Update from lore.kernel.org if: steps.needs-update.outputs.result == 'true' run: | - git fetch "$SOURCE_REPOSITORY" refs/heads/master:refs/heads/lore-$LORE_EPOCH + git fetch "$SOURCE_REPOSITORY" refs/heads/master:"$MIRROR_REF" - name: obtain installation token if: steps.needs-update.outputs.result == 'true' uses: actions/create-github-app-token@v2 @@ -51,4 +51,4 @@ jobs: env: GITHUB_TOKEN: ${{ steps.token.outputs.token }} run: | - git push https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$TARGET_GITHUB_REPOSITORY lore-$LORE_EPOCH + git push https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$TARGET_GITHUB_REPOSITORY "$MIRROR_REF" diff --git a/.github/workflows/sync-upstream-branches.yml b/.github/workflows/sync-upstream-branches.yml index f1c39de..68530bd 100644 --- a/.github/workflows/sync-upstream-branches.yml +++ b/.github/workflows/sync-upstream-branches.yml @@ -16,13 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - spec: - - sourceRepo: j6t/git-gui - targetRepo: gitgitgadget/git - targetRefNamespace: git-gui/ - - sourceRepo: gitster/git - targetRepo: gitgitgadget/git - sourceRefRegex: "^refs/heads/(maint-\\d|[a-z][a-z]/)" + spec: ${{ fromJSON(vars.CONFIG).syncUpstreamBranches }} steps: - name: check which refs need to be synchronized diff --git a/.github/workflows/update-mail-to-commit-notes.yml b/.github/workflows/update-mail-to-commit-notes.yml index bedc4c8..5937e64 100644 --- a/.github/workflows/update-mail-to-commit-notes.yml +++ b/.github/workflows/update-mail-to-commit-notes.yml @@ -11,15 +11,17 @@ concurrency: jobs: update-mail-to-commit-notes: runs-on: ubuntu-latest + if: vars.CONFIG != '' steps: - uses: actions/create-github-app-token@v1 - id: gitgitgadget-git-token + id: pr-repo-token with: app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }} - owner: gitgitgadget - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.owner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: gitgitgadget/gitgitgadget/update-mail-to-commit-notes@v1 with: - pr-repo-token: ${{ steps.gitgitgadget-git-token.outputs.token }} + config: ${{ vars.CONFIG }} + pr-repo-token: ${{ steps.pr-repo-token.outputs.token }} diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index 6de7cb1..1637aa3 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -10,31 +10,35 @@ concurrency: jobs: update-prs: runs-on: ubuntu-latest + if: vars.CONFIG != '' steps: - uses: actions/create-github-app-token@v1 - id: gitgitgadget-git-token + id: pr-repo-token with: app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }} - owner: gitgitgadget - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.owner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: actions/create-github-app-token@v1 - id: git-git-token + if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.baseOwner) }} + id: upstream-repo-token with: app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }} - owner: git - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.baseOwner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: actions/create-github-app-token@v1 - id: dscho-git-token + if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.testOwner) }} + id: test-repo-token with: app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }} private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }} - owner: dscho - repositories: git + owner: ${{ fromJSON(vars.CONFIG).repo.testOwner }} + repositories: ${{ fromJSON(vars.CONFIG).repo.name }} - uses: gitgitgadget/gitgitgadget/update-prs@v1 with: - pr-repo-token: ${{ steps.gitgitgadget-git-token.outputs.token }} - upstream-repo-token: ${{ steps.git-git-token.outputs.token }} - test-repo-token: ${{ steps.dscho-git-token.outputs.token }} + config: ${{ vars.CONFIG }} + pr-repo-token: ${{ steps.pr-repo-token.outputs.token }} + upstream-repo-token: ${{ steps.upstream-repo-token.outputs.token }} + test-repo-token: ${{ steps.test-repo-token.outputs.token }}