Use SSH deploy key instead of account token for theme submodule
Build and deploy / build-and-deploy (push) Failing after 2m43s
Build and deploy / build-and-deploy (push) Failing after 2m43s
Avoids tying CI to a personal/bot Gitea account: the same DEPLOY_SSH_KEY secret used for the webserver rsync step is reused as a read-only Gitea deploy key on hmk/pelican-latex. The submodule's tracked HTTPS URL is overridden to SSH just for this checkout so it authenticates with that key instead of needing a token with access to both repos.
This commit is contained in:
@@ -15,14 +15,31 @@ jobs:
|
|||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y --no-install-recommends git rsync openssh-client nodejs
|
apt-get install -y --no-install-recommends git rsync openssh-client nodejs
|
||||||
|
|
||||||
- name: Checkout (incl. theme submodule)
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: false
|
||||||
# Default job token only covers this repo; the theme submodule
|
|
||||||
# (hmk/pelican-latex) is a separate private repo, so a token with
|
- name: Set up SSH key
|
||||||
# read access to both is needed here.
|
# Same key used both as the theme repo's deploy key (Gitea) and for
|
||||||
token: ${{ secrets.CHECKOUT_TOKEN }}
|
# the webserver login (below) — one secret, two authorized_keys entries.
|
||||||
|
env:
|
||||||
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key
|
||||||
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
ssh-keyscan -H git.haemka.in "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null
|
||||||
|
|
||||||
|
- name: Fetch theme submodule
|
||||||
|
run: |
|
||||||
|
# Override the submodule's tracked HTTPS URL for this checkout only,
|
||||||
|
# so it's fetched over SSH with the deploy key instead of needing a
|
||||||
|
# token with access to both repos.
|
||||||
|
git config submodule.themes/latex.url git@git.haemka.in:hmk/pelican-latex.git
|
||||||
|
GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=yes" \
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
run: pip install --no-cache-dir -r requirements.txt
|
run: pip install --no-cache-dir -r requirements.txt
|
||||||
@@ -35,12 +52,7 @@ jobs:
|
|||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
|
||||||
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key
|
|
||||||
chmod 600 ~/.ssh/deploy_key
|
|
||||||
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null
|
|
||||||
rsync -avz --delete \
|
rsync -avz --delete \
|
||||||
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=yes" \
|
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=yes" \
|
||||||
output/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}"
|
output/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}"
|
||||||
|
|||||||
Reference in New Issue
Block a user