-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.yml
68 lines (63 loc) · 1.94 KB
/
action.yml
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
63
64
65
66
67
68
name: upstream_sync
description: >
Automatically sync branch from upstream repository.
inputs:
upstreamRepo:
description: Upstream repository slug (owner/repo).
default: The-OpenROAD-Project/OpenROAD
upstreamBranch:
description: Upstream branch name to update.
default: master
force:
description: Use a force push.
default: false
deployKey:
description: SSH Private "deploy key" which has write access.
required: true
runs:
using: composite
steps:
- name: Updating '${{ inputs.upstreamBranch }}' from ${{ inputs.upstreamRepo }}
env:
FORCE: ${{ inputs.force }}
shell: bash
run: |
# Configure ssh to ignore host key checking.
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "::group::Existing ssh config file"
cat ~/.ssh/config || true
echo "::endgroup::"
cat > ~/.ssh/config << EOF
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
EOF
# Figure out if we should do a force push
export GIT_ARGS=''
if [[ x$FORCE = 'xtrue' ]]; then
export GIT_ARGS=--force
fi
# Clone a blobless repository and don't bother checking it out.
echo "::group::Clone repo"
rm -rf repo
git clone \
--filter=blob:none \
--no-tags \
--no-checkout \
--origin upstream \
--branch ${{ inputs.upstreamBranch }} \
--verbose \
https://github.com/${{ inputs.upstreamRepo }}.git \
repo
cd repo
echo "::endgroup::"
# Start ssh agent and add deploy key.
eval $(ssh-agent -s)
ssh-add - <<< "${{ inputs.deployKey }}"
# Add local repository and push to it.
echo "::group::Push repo"
git remote add origin git+ssh://git@github.com/${{ github.repository }}.git
git push origin $GIT_ARGS --verbose upstream/${{ inputs.upstreamBranch }}:${{ inputs.upstreamBranch }}
echo "::endgroup::"
kill $SSH_AGENT_PID