Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

circleci_deploy_key

circleci_deploy_key #1

name: circleci_deploy_key
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Registration routine
shell: bash
env:
CCI_TOKEN: ${{ secrets.TEAM_BERLIN_MACHINE_USER_CCI_TOKEN }}
GH_TOKEN: ${{ secrets.TEAM_BERLIN_MACHINE_USER_REPO_TOKEN }}
run: |
ssh-keygen -t ed25519 -N '' -q -f ./cci_deploy
curl -L \
-X POST \
--no-progress-meter \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${GITHUB_REPOSITORY}/keys \
-d '{"title":"CircleCI","key":"'"$(< cci_deploy.pub)"'","read_only":false}'
curl -X POST \
--no-progress-meter \
-H "Content-Type: application/json" \
-H "Circle-Token: $CCI_TOKEN" \
https://circleci.com/api/v1.1/project/gh/${GITHUB_REPOSITORY}/ssh-key \
-d '{"hostname":"github.com","private_key":"'"$(< cci_deploy)"'"}'
echo "Fingerprint: "
ssh-keygen -E md5 -lf cci_deploy | cut -d ' ' -f 2 | sed 's/MD5://'