2020 - update-templates
2121
2222env :
23+ BASE_IMAGE_RAW : ${{ github.event.client_payload.base_image || inputs.base_image }}
2324 RAW_BRANCH_NAME : ci/${{ github.event.client_payload.base_image || inputs.base_image }}
2425 BASE_IMAGE : ${{ github.event.client_payload.base_image || inputs.base_image }}
2526 DEFAULT_RUNTIME_VERSION : ${{ github.event.client_payload.default_runtime_version || inputs.default_runtime_version }}
@@ -68,19 +69,21 @@ jobs:
6869
6970 - name : Run update script
7071 env :
71- BASE_IMAGE : ${{ steps.branch-name.outputs.BRANCH_NAME }}
72+ BASE_IMAGE : ${{ env.BASE_IMAGE_RAW }}
7273 DEFAULT_RUNTIME_VERSION : ${{ env.DEFAULT_RUNTIME_VERSION }}
7374 MODULE_VERSION : ${{ env.MODULE_VERSION }}
7475 run : node ./scripts/actions/update-templates.mts
7576
7677 - name : Commit and push changes
78+ id : commit-and-push
7779 run : |
7880 # Check if there are any changes
7981 if git diff --quiet && git diff --cached --quiet; then
8082 echo "No changes to commit"
8183 else
8284 git add -A
83- git commit -m "chore: Update templates for base image: ${{ steps.branch-name.outputs.BRANCH_NAME }}"
85+ git commit -m "chore: Update templates for base image: ${{ env.BASE_IMAGE_RAW }}"
86+ echo "committed=true" >> $GITHUB_OUTPUT
8487 fi
8588
8689 # Force push the branch
8992 - name : Create Pull Request
9093 env :
9194 GH_TOKEN : ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
95+ if : steps.commit-and-push.outputs.committed == 'true'
9296 run : |
9397 # Check if PR already exists
9498 PR_EXISTS=$(gh pr list --head "${{ steps.branch-name.outputs.BRANCH_NAME }}" --base master --json number --jq length)
@@ -97,10 +101,10 @@ jobs:
97101 echo "Creating new PR"
98102 gh pr create \
99103 --title "chore: Update templates for base image: ${{ steps.branch-name.outputs.BRANCH_NAME }}" \
100- --body "Automated update of templates for base image \`${{ steps.branch-name.outputs.BRANCH_NAME }}\`
104+ --body "Automated update of templates for base image \`${{ env.BASE_IMAGE_RAW }}\`
101105
102106 **Parameters:**
103- - Base Image: \`${{ steps.branch-name.outputs.BRANCH_NAME }}\`
107+ - Base Image: \`${{ env.BASE_IMAGE_RAW }}\`
104108 - Runtime Version: \`${{ env.DEFAULT_RUNTIME_VERSION }}\`
105109 - Module Version: \`${{ env.MODULE_VERSION || 'N/A' }}\`
106110
@@ -110,6 +114,18 @@ jobs:
110114 --reviewer B4nan \
111115 --reviewer vladfrangu
112116 else
113- echo "PR already exists for branch ${{ steps.branch-name.outputs.BRANCH_NAME }}"
117+ echo "PR already exists for branch ${{ steps.branch-name.outputs.BRANCH_NAME }}, updating it"
118+
119+ # gh pr edit supports a branch name or a PR number or a URL
120+
121+ gh pr edit "${{ steps.branch-name.outputs.BRANCH_NAME }}" \
122+ --body "Automated update of templates for base image \`${{ env.BASE_IMAGE_RAW }}\`
123+
124+ **Parameters:**
125+ - Base Image: \`${{ env.BASE_IMAGE_RAW }}\`
126+ - Runtime Version: \`${{ env.DEFAULT_RUNTIME_VERSION }}\`
127+ - Module Version: \`${{ env.MODULE_VERSION || 'N/A' }}\`
128+
129+ This PR was automatically generated by the [Update Templates](https://github.com/apify/actor-templates/actions/workflows/update-templates.yml) workflow."
114130 fi
115131
0 commit comments