diff --git a/.github/actions/push/action.yml b/.github/actions/push/action.yml index da2b7dbd3..8acb5c78f 100644 --- a/.github/actions/push/action.yml +++ b/.github/actions/push/action.yml @@ -29,12 +29,16 @@ runs: run: | git config --global user.name "${{ inputs.user }}" git config --global user.email "${{ inputs.user }}@users.noreply.github.com" + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock shell: bash - name: Git Commit if: ${{ inputs.message != '' }} run: | git add . git commit -m "${{ inputs.message }}" + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock shell: bash - name: Push Changes run: | @@ -42,4 +46,6 @@ runs: if [ ${{ inputs.tags }} = 'true' ]; then git push --tags fi + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock shell: bash diff --git a/.github/actions/ssh/action.yml b/.github/actions/ssh/action.yml new file mode 100644 index 000000000..70626bd4a --- /dev/null +++ b/.github/actions/ssh/action.yml @@ -0,0 +1,26 @@ +name: 'SSH' +description: 'Setup ssh key.' + +branding: + icon: key + color: green + +inputs: + ssh-key: + description: 'SSH key' + required: true + +runs: + using: "composite" + steps: + - name: Add SSH key + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + mkdir -p /home/runner/.ssh + ssh-keyscan github.com >> /home/runner/.ssh/known_hosts + echo "${{ inputs.ssh-key }}" > /home/runner/.ssh/github_actions + chmod 600 /home/runner/.ssh/github_actions + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add /home/runner/.ssh/github_actions + shell: bash diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 11c973a27..29096bf9a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -60,3 +60,5 @@ jobs: run: yarn install - name: Check changesets run: yarn changeset status --since origin/main + + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index da6138e19..9afb6371f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,11 +16,11 @@ jobs: uses: actions/checkout@v4 with: ssh-key: ${{ secrets.GH_DEPLOY_KEY }} - - name: Configure Git - run: | - git remote set-url origin ssh://git@github.com/${{ github.repository }} - git clone --depth 1 ssh://git@github.com/${{ github.repository }} abc - git clone --depth 1 git@github.com/${{ github.repository }} xyz + persist-credentials: false + - name: Setup SSH + uses: ./.github/actions/ssh + with: + ssh-key: ${{ secrets.GH_DEPLOY_KEY }} - name: Setup Anchor uses: ./.github/actions/anchor - name: Install dependencies @@ -36,6 +36,7 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} + SSH_AUTH_SOCK: /tmp/ssh_agent.sock - name: Tag Release run: yarn changeset tag - name: Push Changes