forked from nvaccess/nvda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User docs github action: push via ssh / deploy key (nvaccess#17100)
Due to very good and strict permissions on branches such as beta, A normal GitHub action token cannot push to the branch. Description of development approach Push via ssh using a deploy key.
- Loading branch information
1 parent
3524568
commit 8b48583
Showing
1 changed file
with
12 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,20 +53,29 @@ jobs: | |
if: success() | ||
|
||
- name: Commit and Push changes | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
$ErrorActionPreference = 'Stop' | ||
git config --local user.name "GitHub Actions" | ||
git config --local user.email "[email protected]" | ||
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git | ||
$filesChanged = git diff --name-only -- *.xliff | ||
if ($filesChanged) { | ||
Write-Host "xliff files were changed. Committing and pushing changes." | ||
foreach ($file in $filesChanged) { | ||
git add $file | ||
Write-Host "Committing $file" | ||
git commit -m "Update $file" | ||
} | ||
Write-Host "Setting up ssh for push" | ||
# Ensure .ssh directory exists | ||
New-Item -ItemType Directory -Force -Path ~/.ssh | ||
# Add github.com to the list of known hosts for ssh | ||
ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
# set the private key of the Github deploy key as the ssh key | ||
$privateKey = "${{ secrets.XLIFF_DEPLOY_PRIVATE_KEY }}" | ||
$privateKey | Out-File -FilePath ~/.ssh/id_rsa -Encoding ascii | ||
# Tell git to use ssh for pushing | ||
git remote set-url origin [email protected]:${{ github.repository }} | ||
Write-Host "Pushing changes" | ||
git push origin HEAD | ||
} else { | ||
Write-Host "No xliff files were changed. Skipping commit and push." | ||
|