-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
79 lines (72 loc) · 2.84 KB
/
action.yml
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
71
72
73
74
75
76
77
78
79
name: 'Use The Source Deploy Maven Releases'
description: 'Special github action to help with maven deploy to our release server'
inputs:
maven-username:
description: 'Maven HTTP username'
required: true
maven-password:
description: 'Maven HTTP password'
required: true
maven-local-port:
description: 'Local port number for maven'
required: true
ssh-hostname:
description: 'SSH server hostname to connect to'
required: true
ssh-known-host:
description: 'SSH server-keys for the usethesource server, generate it with `ssh-keyscan -H <server-hostname>`'
required: true
ssh-username:
description: 'SSH username'
required: true
ssh-private-key:
description: 'SSH private key of which the public key is registered for the user (.ssh/authorized_keys), please make id an ed25519 key'
required: true
working-directory:
description: 'Current working directory'
required: false
default: '.'
maven-options:
required: false
description: 'Extra maven options'
default: ''
runs:
using: "composite"
steps:
- id: "Assure valid keys are set"
if: ${{ inputs.ssh-prvate-key == '' || inputs.ssh-known-hosts == '' || inputs.maven-username == '' }}
run: |
echo "*** ERROR! ****"
echo "The action did not get the parameters supplied. In most cases this is due to lacking rights for the usethesource secrets"
echo "Please provide this and run the action again"
exit 1
- id: gen-settings_xml
run: |
sed \
-e "s/__USERNAME__/${{ inputs.maven-username }}/g" \
-e "s/__PASSWORD__/${{ inputs.maven-password }}/g" \
"$GITHUB_ACTION_PATH/settings-template.xml" > "$HOME/.m2/settings.xml"
shell: bash
- id: install-ssh-key
run: |
mkdir -p ~/.ssh/
echo "${{ inputs.ssh-private-key }}" > ~/.ssh/id_ed25519
echo "${{ inputs.ssh-known-host }}" >> ~/.ssh/known_hosts
chmod -R og-rwx ~/.ssh/
ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub
chmod og+r ~/.ssh/known_hosts
echo "Host *" >> ~/.ssh/config
echo "ServerAliveInterval 240" >> ~/.ssh/config
echo "ServerAliveCountMax 2" >> ~/.ssh/config
shell: bash
- id: deploy
run: |
cd ${{ inputs.working-directory }}
echo "Starting tunnel in background"
ssh -o LogLevel=ERROR -N -L 8888:localhost:${{ inputs.maven-local-port }} ${{ inputs.ssh-username }}@${{ inputs.ssh-hostname }} &
echo "Running maven deploy"
mvn verify org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy -B -DskipTests -DaltReleaseDeploymentRepository=usethesource-releases::http://localhost:8888/maven/ ${{ inputs.maven-options }}
shell: bash
- id: cleanup-files-with-secrets
run: rm ~/.m2/settings.xml ~/.ssh/id_ed25519
shell: bash