feat: convert the user_deploy into a dockerfile

This commit is contained in:
silver 2024-09-23 20:51:16 +01:00
parent f5b842547a
commit 0461015a46
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D
4 changed files with 40 additions and 23 deletions

8
deploy_user/Dockerfile Normal file
View file

@ -0,0 +1,8 @@
# Container image that runs your code
FROM node:22-bullseye
# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh
# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -6,8 +6,7 @@ inputs:
required: true
username:
description: 'Pass in your skynet username'
required: false
default: ${{ env.GITHUB_REPOSITORY_OWNER }}
required: true
folder:
description: 'Folder to upload, normally build'
required: true
@ -16,23 +15,10 @@ inputs:
required: false
default: ""
runs:
using: "composite"
steps:
- name: "Set SSH key"
shell: bash
run: |
# jank I know
echo "${{ inputs.ssh_key }}" > tmp.key
chmod 600 tmp.key
- name: "Ensure public_html exists"
shell: bash
run: |
ssh -v -i tmp.key ${{ inputs.username }}@skynet.skynet.ie "mkdir -p ~/public_html && chmod 711 ~ || true && chmod -R 755 ~/public_html || true"
- name: "Ensure destination exists"
shell: bash
run: |
ssh -v -i tmp.key ${{ inputs.username }}@skynet.skynet.ie "mkdir -p ~/public_html/${{ inputs.destination }}"
- name: "Copy files across"
shell: bash
run: |
scp -v -i tmp.key -r ${{ inputs.folder }}/* ${{ inputs.username }}@skynet.skynet.ie:/home/${{ inputs.username }}/public_html/${{ inputs.destination }}
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.username }}
- ${{ inputs.ssh_key }}
- ${{ inputs.folder }}
- ${{ github.destination }}

23
deploy_user/entrypoint.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/sh
export USERNAME=$1
export SSH_KEY=$2
export FOLDER=$3
export DESTINATION=$4
# make sure the ssh agent is running
eval `ssh-agent -s`
# for the deploy
echo "${SSH_KEY}" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "$SSH_KEY" >> ~/.ssh/id_rsa
# ensure teh public_html is created and has right permissions
ssh -vvv -i ~/.ssh/id_rsa ${USERNAME}@skynet.skynet.ie "mkdir -p ~/public_html && chmod 711 ~ || true && chmod -R 755 ~/public_html || true"
# ensure output folder exists
ssh -v ${USERNAME}@skynet.skynet.ie "mkdir -p ~/public_html/${DESTINATION}"
# copy files across
scp -v -r ${FOLDER}/* ${USERNAME}@skynet.skynet.ie:/home/${USERNAME}/public_html/${DESTINATION}

View file

@ -1,5 +1,5 @@
# Container image that runs your code
FROM node:16-bullseye
FROM node:22-bullseye
# make sure dependencies are installed
RUN apt-get -y update