Add reusable workflow for setting up SSH agent
This commit is contained in:
parent
0e8ce1d7a7
commit
8af6aeceb6
2 changed files with 35 additions and 11 deletions
27
.github/workflows/ssh.yml
vendored
Normal file
27
.github/workflows/ssh.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
name: Set up SSH agent
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
config:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
known-hosts:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
env:
|
||||||
|
SSH_AUTH_SOCK: /tmp/ssh-agent.sock
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ssh-agent:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Set up SSH agent
|
||||||
|
run: |
|
||||||
|
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
|
||||||
|
ssh-add - <<< '${{ secrets.SSH_PRIVATE_KEY }}'
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo '${{ inputs.config }}' > ~/.ssh/config
|
||||||
|
echo '${{ inputs.known-hosts }}' > ~/.ssh/known_hosts
|
19
.github/workflows/stage.yml
vendored
19
.github/workflows/stage.yml
vendored
|
@ -3,9 +3,6 @@ name: Deploy (Staging)
|
||||||
on:
|
on:
|
||||||
workflow_dispatch
|
workflow_dispatch
|
||||||
|
|
||||||
env:
|
|
||||||
SSH_AUTH_SOCK: /tmp/ssh-agent.sock
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stage:
|
stage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -29,17 +26,17 @@ jobs:
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew installDist
|
run: ./gradlew installDist
|
||||||
|
|
||||||
- name: Set up SSH agent
|
- uses: ./.github/workflows/ssh.yml
|
||||||
run: |
|
with:
|
||||||
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
|
config: ${{ vars.SSH_CONFIG }}
|
||||||
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
|
known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}
|
||||||
mkdir -p ~/.ssh
|
secrets: inherit
|
||||||
echo '${{ vars.SSH_CONFIG }}' > ~/.ssh/config
|
|
||||||
echo '${{ vars.KNOWN_HOSTS }}' > ~/.ssh/known_hosts
|
|
||||||
|
|
||||||
- name: Publish to staging server
|
- name: Publish to staging server
|
||||||
|
# The rsync command applies the same filters as the one in tools/extras/deploy.sh
|
||||||
run: |
|
run: |
|
||||||
rsync build/install/helma/ antville.dev:/ \
|
ssh antville.dev ping
|
||||||
|
echo rsync ./build/install/helma/ antville.dev:./ \
|
||||||
--verbose --archive --delete --compress \
|
--verbose --archive --delete --compress \
|
||||||
--filter 'protect /lib/ext' \
|
--filter 'protect /lib/ext' \
|
||||||
--filter '+ /launcher.jar' \
|
--filter '+ /launcher.jar' \
|
||||||
|
|
Loading…
Add table
Reference in a new issue