Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 2912f9f

Browse files
committed
ci: remove images: Push to main via ssh
Signed-off-by: John Andersen <[email protected]>
1 parent abb6e22 commit 2912f9f

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

.github/workflows/remove_images.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
REPO_URL: https://github.com/intel/dffml
2525
BRANCH: master
2626
GIT_FILTER_REPO_PATHS: /tmp/git-filter-repo-paths
27+
SSH_DFFML_GH_PAGES: ${{ secrets.SSH_DFFML_GH_PAGES }}
2728
shell: bash -xe {0}
2829
run: |
2930
git init
@@ -40,10 +41,28 @@ jobs:
4041
EOF
4142
git filter-repo --force --invert-paths --paths-from-file $GIT_FILTER_REPO_PATHS
4243
git log --stat | grep -E '\.png|\.jpeg|\.jpg|\.gif'
43-
- name: Push
44-
env:
45-
BRANCH: main
46-
shell: bash -xe {0}
47-
run: |
48-
git checkout -b $BRANCH
49-
git push -u origin $BRANCH
44+
45+
export GIT_SSH_COMMAND='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
46+
47+
TEMP_DIRS=()
48+
49+
function cleanup_temp_dirs() {
50+
for temp_dir in ${TEMP_DIRS[@]}; do
51+
rm -rf "${temp_dir}"
52+
done
53+
}
54+
55+
# Clean up temporary directories on exit
56+
trap cleanup_temp_dirs EXIT
57+
58+
ssh_key_dir="$(mktemp -d)"
59+
TEMP_DIRS+=("${ssh_key_dir}")
60+
mkdir -p ~/.ssh
61+
chmod 700 ~/.ssh
62+
python -c "import pathlib, base64, os; keyfile = pathlib.Path(\"${ssh_key_dir}/github\").absolute(); keyfile.write_bytes(b''); keyfile.chmod(0o600); keyfile.write_bytes(base64.b32decode(os.environ['SSH_DFFML_GH_PAGES']))"
63+
ssh-keygen -y -f "${ssh_key_dir}/github" > "${ssh_key_dir}/github.pub"
64+
export GIT_SSH_COMMAND="${GIT_SSH_COMMAND} -o IdentityFile=${ssh_key_dir}/github"
65+
66+
git remote set-url origin [email protected]:intel/dffml
67+
git checkout -b main
68+
git push -u origin main

0 commit comments

Comments
 (0)