Replaced secrets with inputs.

This commit is contained in:
Alexander Artemenko 2021-02-06 20:38:00 +03:00
parent c82f20df5b
commit a44a6e8e4a
2 changed files with 17 additions and 8 deletions

View file

@ -7,6 +7,12 @@ inputs:
qlfile-template: qlfile-template:
description: "Djula template for qlfile. All environment variables are available in it's context" description: "Djula template for qlfile. All environment variables are available in it's context"
required: false required: false
SSH_PASS:
description: 'Password for SSH session'
required: true
NGROK_AUTH_TOKEN:
description: 'Authentification token for ngrok'
required: true
runs: runs:
using: composite using: composite
@ -25,12 +31,12 @@ runs:
- name: Check inputs - name: Check inputs
run: | run: |
if [ -z "${{ secrets.SSH_PASS }}" ] if [ -z "${{ inputs.SSH_PASS }}" ]
then then
echo "SSH_PASS needs to be passed in the 'with' field." echo "SSH_PASS needs to be passed in the 'with' field."
exit 1 exit 1
fi fi
if [ -z "${{ secrets.NGROK_AUTH_TOKEN }}" ] if [ -z "${{ inputs.NGROK_AUTH_TOKEN }}" ]
then then
echo "NGROK_AUTH_TOKEN needs to be passed in the 'with' field." echo "NGROK_AUTH_TOKEN needs to be passed in the 'with' field."
exit 1 exit 1
@ -46,7 +52,7 @@ runs:
printf " [DONE]\n\n" printf " [DONE]\n\n"
echo "# Change the SSH user password" echo "# Change the SSH user password"
echo "${{ secrets.SSH_PASS }}`n${{ secrets.SSH_PASS }}" | sudo passwd $(cat ssh_user) echo "${{ inputs.SSH_PASS }}`n${{ inputs.SSH_PASS }}" | sudo passwd $(cat ssh_user)
} }
elseif('${{ runner.os }}' -eq 'macOS') elseif('${{ runner.os }}' -eq 'macOS')
{ {
@ -59,7 +65,7 @@ runs:
echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config >/dev/null echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config >/dev/null
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
echo "${{ secrets.SSH_PASS }}`n${{ secrets.SSH_PASS }}" | sudo passwd "root" echo "${{ inputs.SSH_PASS }}`n${{ inputs.SSH_PASS }}" | sudo passwd "root"
} }
elseif('${{ runner.os }}' -eq 'Windows') elseif('${{ runner.os }}' -eq 'Windows')
{ {
@ -90,7 +96,7 @@ runs:
net start BvSshServer net start BvSshServer
echo "# Change the SSH user password" echo "# Change the SSH user password"
net user $env:UserName ${{ secrets.SSH_PASS }} net user $env:UserName ${{ inputs.SSH_PASS }}
} }
shell: pwsh shell: pwsh
@ -101,13 +107,13 @@ runs:
unzip ngrok.zip unzip ngrok.zip
chmod +x ./ngrok chmod +x ./ngrok
echo "# Set ngrok with the given authentification token" echo "# Set ngrok with the given authentification token"
./ngrok authtoken ${{ secrets.NGROK_AUTH_TOKEN }} ./ngrok authtoken ${{ inputs.NGROK_AUTH_TOKEN }}
shell: bash shell: bash
- name: Start ngrok - name: Start ngrok
run: | run: |
printf "# Starting ngrok..." printf "# Starting ngrok..."
./ngrok tcp 22 --log ".ngrok.log" --region "${{ secrets.NGROK_REGION }}" & ./ngrok tcp 22 --log ".ngrok.log" --region "${{ inputs.NGROK_REGION }}" &
printf " [DONE]\n\n" printf " [DONE]\n\n"
printf "# Waiting for '.ngrok.log' file to be properly generated..." printf "# Waiting for '.ngrok.log' file to be properly generated..."
while ! grep -osqE "tcp://(.+)" .ngrok.log;do while ! grep -osqE "tcp://(.+)" .ngrok.log;do
@ -120,7 +126,7 @@ runs:
printf " [DONE]\n\n" printf " [DONE]\n\n"
ssh_string=$(grep -oE "tcp://(.+)" .ngrok.log | sed "s/tcp:\/\//ssh $(cat ssh_user)@/" | sed "s/:/ -p /") ssh_string=$(grep -oE "tcp://(.+)" .ngrok.log | sed "s/tcp:\/\//ssh $(cat ssh_user)@/" | sed "s/:/ -p /")
continue_path=$(eval echo ~$(cat ssh_user)/continue) continue_path=$(eval echo ~$(cat ssh_user)/continue)
time=${{ secrets.NGROK_TIMEOUT }} time=${{ inputs.NGROK_TIMEOUT }}
while [ ! -e $continue_path ] && [ $time -gt 1 ] while [ ! -e $continue_path ] && [ $time -gt 1 ]
do do
echo "" echo ""

View file

@ -38,3 +38,6 @@ jobs:
- uses: 40ants/cl-info/.github/actions/build-docs@custom-action - uses: 40ants/cl-info/.github/actions/build-docs@custom-action
with: with:
asdf-system: cl-info asdf-system: cl-info
with:
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
SSH_PASS: ${{ secrets.SSH_PASS }}