From 3e1414573935082f3dcd1a265e939ebd67067afd Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Sun, 4 Jun 2023 08:44:53 +0200 Subject: [PATCH 1/2] docs: Add protected branch support to the documentation --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bcd2074..150e16b 100644 --- a/README.md +++ b/README.md @@ -100,8 +100,8 @@ jobs: token: ${{ secrets.PAT_TOKEN }} - name: Commit files run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" + git config --local user.email "test@test.com" + git config --local user.name "Test" git commit -a -m "Add changes" - name: Push changes uses: ad-m/github-push-action@master @@ -162,6 +162,31 @@ jobs: branch: ${{ github.ref }} ``` +An example workflow to push to a protected branch inside your own repository. Be aware that it's necessary to use a personal access token, and maybe it is a good idea to specify the force-with-lease flag in case of sync and push errors: + +```yaml +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + token: ${{ secrets.PAT_TOKEN }} + - name: Commit files + run: | + git config --local user.email "test@test.com" + git config --local user.name "Test" + git commit -a -m "Add changes" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.PAT_TOKEN }} + repository: Test/test + force_with_lease: true +``` + ### Inputs | name | value | default | description | From 63a2919535621a8bf6f24977bd34b1c2ac5ccaed Mon Sep 17 00:00:00 2001 From: Pascal Zimmermann Date: Sat, 26 Aug 2023 23:18:48 +0200 Subject: [PATCH 2/2] docs: Adjust the GitHub App Token documentation --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 150e16b..42f2e6e 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,36 @@ jobs: force_with_lease: true ``` +An example workflow to use a GitHub App Token together with the default token inside the checkout action. You can find more information on the topic [here](https://github.com/ad-m/github-push-action/issues/173): + +```yaml +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + persist-credentials: false + - name: Generate Githup App Token + id: generate_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.APP_ID }} + installation_id: ${{ secrets.INSTALLATION_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + - name: Commit files + run: | + git config --local user.email "test@test.com" + git config --local user.name "Test" + git commit -a -m "Add changes" + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ env.TOKEN }} +``` + An example workflow to use the non default token push to another repository. Be aware that the force-with-lease flag is in such a case not possible: ```yaml