Skip to content

Commit 725ffa7

Browse files
committed
Fix permissions: enable contents write and persist credentials
1 parent f693de2 commit 725ffa7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.github/workflows/publish-conan.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
publish:
1010
runs-on: ubuntu-latest
1111
permissions:
12-
contents: read
12+
contents: write
1313
pull-requests: write
1414

1515
steps:
@@ -36,6 +36,7 @@ jobs:
3636
repository: d-led/conan-center-index
3737
path: conan-center-index
3838
token: ${{ secrets.GITHUB_TOKEN }}
39+
persist-credentials: true
3940

4041
- name: Setup conan-center-index upstream
4142
working-directory: conan-center-index

scripts/publish-conan-version.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,15 @@ git commit -m "Add influxdb-cpp-rest/${VERSION}
235235

236236
# Push branch
237237
echo "Pushing branch..."
238+
# In CI, credentials should be persisted from checkout action
239+
# If GITHUB_TOKEN is available and remote doesn't have credentials, update it
238240
if [ -n "${GITHUB_TOKEN:-}" ]; then
239-
# Use token for CI environment
240-
git remote set-url origin "https://${GITHUB_TOKEN}@github.com/${CONAN_INDEX_FORK}.git"
241+
# Check if remote already has credentials (from persist-credentials)
242+
CURRENT_URL=$(git remote get-url origin)
243+
if [[ ! "$CURRENT_URL" =~ @github\.com ]]; then
244+
# Remote URL doesn't have credentials, add token
245+
git remote set-url origin "https://${GITHUB_TOKEN}@github.com/${CONAN_INDEX_FORK}.git"
246+
fi
241247
fi
242248
git push -u origin "${BRANCH_NAME}" || git push origin "${BRANCH_NAME}"
243249

0 commit comments

Comments
 (0)