@@ -83,13 +83,22 @@ jobs:
8383
8484 # TODO: remove this step once system images are EOL
8585 - name : Temporarily disable "include administrators" branch protection
86- if : ${{ always() && github.ref == 'refs/heads/main' }}
86+ if : always() && github.ref == 'refs/heads/main'
8787 id : disable_include_admins
88- uses : benjefferies/branch-protection-bot@af281f37de86139d1c7a27b91176b5dc1c2c827c # v1.1.2
88+ uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
8989 with :
90- access_token : ${{ secrets.REPO_GHA_PAT }}
91- branch : main
92- enforce_admins : false
90+ github-token : ${{ secrets.REPO_GHA_PAT }}
91+ script : |
92+ const params = {
93+ owner: 'cloudnative-pg',
94+ repo: 'postgres-containers',
95+ branch: 'main',
96+ };
97+ const { data } = await github.rest.repos.getAdminBranchProtection(params);
98+ core.setOutput('initial_status', data.enabled);
99+ if (data.enabled) {
100+ await github.rest.repos.deleteAdminBranchProtection(params);
101+ }
93102
94103 # TODO: remove this step once system images are EOL
95104 - name : Legacy diff
@@ -110,10 +119,17 @@ jobs:
110119 message : ' chore: update imageCatalogs'
111120
112121 # TODO: remove this step once system images are EOL
113- - name : Enable "include administrators" branch protection
114- uses : benjefferies/branch-protection-bot@af281f37de86139d1c7a27b91176b5dc1c2c827c # v1.1.2
115- if : ${{ always() && github.ref == 'refs/heads/main' }}
122+ - name : Restore "include administrators" branch protection
123+ uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
124+ if : |
125+ always() &&
126+ github.ref == 'refs/heads/main' &&
127+ steps.disable_include_admins.outputs.initial_status == 'true'
116128 with :
117- access_token : ${{ secrets.REPO_GHA_PAT }}
118- branch : main
119- enforce_admins : ${{ steps.disable_include_admins.outputs.initial_status }}
129+ github-token : ${{ secrets.REPO_GHA_PAT }}
130+ script : |
131+ await github.rest.repos.setAdminBranchProtection({
132+ owner: 'cloudnative-pg',
133+ repo: 'postgres-containers',
134+ branch: 'main',
135+ });
0 commit comments