Skip to content

Commit b884526

Browse files
deploy changes
1 parent d85c976 commit b884526

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Deploy to Open Repo
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
deploy:
14+
if: github.event.repository.name == 'asparagus'
15+
name: Push built output to target repo via SSH
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository (no persisted credentials)
19+
uses: actions/checkout@v4
20+
with:
21+
ref: deploy
22+
fetch-depth: 0
23+
persist-credentials: false
24+
25+
- name: Configure git author
26+
run: |
27+
git config --global user.name "github-actions[bot]"
28+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
29+
30+
- name: Update deployment branch and remove this workflow so it doesn't get pushed
31+
run: |
32+
git merge --squash -X theirs origin/main --allow-unrelated-histories
33+
git restore --staged README.md
34+
git commit -m "deploy changes"
35+
36+
- name: Start ssh-agent and add deploy key
37+
uses: webfactory/ssh-agent@v0.9.1
38+
with:
39+
ssh-private-key: ${{ secrets.DEPLOY }}
40+
41+
- name: Ensure github.com is in known_hosts
42+
run: |
43+
mkdir -p ~/.ssh
44+
ssh-keyscan github.com >> ~/.ssh/known_hosts
45+
chmod 644 ~/.ssh/known_hosts
46+
47+
- name: Set SSH remote and push via SSH
48+
run: |
49+
echo "Pushing to SSH remote: git@github.com:Sllambias/oasparagus.git -> branch main"
50+
51+
git remote remove origin || true
52+
git remote add ssh-origin git@github.com:Sllambias/oasparagus.git
53+
54+
# Sanity checks
55+
git remote -v
56+
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
57+
ssh -T -o StrictHostKeyChecking=no git@github.com || true
58+
59+
git push --force -u ssh-origin HEAD:main

0 commit comments

Comments
 (0)