-
Notifications
You must be signed in to change notification settings - Fork 166
70 lines (61 loc) · 2.5 KB
/
mirror_to_public.yaml
File metadata and controls
70 lines (61 loc) · 2.5 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
63
64
65
66
67
68
69
70
name: Mirror to Public Repository
on:
push:
branches:
- main
# Serialize runs so rapid pushes don't race and overwrite each other's commits
concurrency:
group: mirror-to-public
jobs:
mirror-history:
name: Mirror to History Branch
runs-on: [tetra-ubuntu-2204, self-hosted]
steps:
- uses: actions/checkout@v6
with:
ref: main-history
- name: Fetch triggering commit and extract metadata
id: meta
run: |
git fetch origin ${{ github.sha }} --depth=1
{
echo "author_name=$(git log -1 ${{ github.sha }} --format='%an')"
echo "author_email=$(git log -1 ${{ github.sha }} --format='%ae')"
echo "author_date=$(git log -1 ${{ github.sha }} --format='%aI')"
echo "committer_name=$(git log -1 ${{ github.sha }} --format='%cn')"
echo "committer_email=$(git log -1 ${{ github.sha }} --format='%ce')"
echo "committer_date=$(git log -1 ${{ github.sha }} --format='%cI')"
} >> "$GITHUB_OUTPUT"
# Message may be multiline; write to a file
git log -1 ${{ github.sha }} --format='%B' > /tmp/commit_message.txt
- name: Mirror to main-history branch
env:
GIT_AUTHOR_NAME: ${{ steps.meta.outputs.author_name }}
GIT_AUTHOR_EMAIL: ${{ steps.meta.outputs.author_email }}
GIT_AUTHOR_DATE: ${{ steps.meta.outputs.author_date }}
GIT_COMMITTER_NAME: ${{ steps.meta.outputs.committer_name }}
GIT_COMMITTER_EMAIL: ${{ steps.meta.outputs.committer_email }}
GIT_COMMITTER_DATE: ${{ steps.meta.outputs.committer_date }}
run: |
# Replace the index with the triggering commit's tree
git read-tree --reset ${{ github.sha }}
if git diff --cached --quiet HEAD; then
echo "No changes to commit"
else
git commit -F /tmp/commit_message.txt
git push origin HEAD:main-history -f
fi
mirror-public:
name: Push to Public Repo
runs-on: [tetra-ubuntu-2204, self-hosted]
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Push commit to public repo main
env:
GH_TOKEN: ${{ secrets.PROD_GH_TOKEN }}
run: |
git config --local credential.helper '!f() { echo "username=x-access-token"; echo "password=$GH_TOKEN"; }; f'
git remote add public https://github.com/qualcomm/ai-hub-models.git
git push public HEAD:main -f