-
Notifications
You must be signed in to change notification settings - Fork 7
62 lines (52 loc) · 1.99 KB
/
deploy_from_open.yaml
File metadata and controls
62 lines (52 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: deploy from open
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: write
jobs:
deploy:
if: |
${{ (github.event.repository.name == 'asparagus' &&
github.event.commits[0].message != 'deploy changes' &&
github.event.commits[0].author.name != 'github-actions[bot]') }}
name: Push built output to target repo via SSH
runs-on: ubuntu-latest
steps:
- name: Checkout repository (no persisted credentials)
uses: actions/checkout@v4
with:
ref: deploy
fetch-depth: 0
persist-credentials: false
- name: Start ssh-agent and add deploy key
uses: webfactory/ssh-agent@v0.9.1
with:
ssh-private-key: ${{ secrets.DEPLOY }}
- name: Configure git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/Sllambias/asparagus
git remote add ssh-origin git@github.com:Sllambias/internal_asparagus.git
- name: Ensure github.com is in known_hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Update deploy branch and commit changes
run: |
git fetch ssh-origin main
git rebase -X ours ssh-origin/main
git merge --squash -X theirs origin/main --allow-unrelated-histories
git restore --staged README.md
git commit -m "deploy changes"
- name: Sync repositories
run: |
echo "Pushing to SSH remote: git@github.com:Sllambias/internal_asparagus.git -> branch main"
git remote -v
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
ssh -T -o StrictHostKeyChecking=no git@github.com || true
git push -u ssh-origin HEAD:main