Skip to content

πŸš€ Deploy marmadilemanteater.dev #202

πŸš€ Deploy marmadilemanteater.dev

πŸš€ Deploy marmadilemanteater.dev #202

# This is a basic workflow to help you get started with Actions
name: πŸš€ Deploy `marmadilemanteater.dev`
# Controls when the workflow will run
on:
schedule:
- cron: "30 1 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allow one concurrent deployment
concurrency:
group: "marmadilemanteater-dev"
cancel-in-progress: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: ⬇ Download SimpleReverseProxy artifact
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
workflow: main.yml
workflow_conclusion: success
branch: development
path: ./artifacts/
# only download the version built for OpenSSL 1.1.1f because it is what I am running on my linode
name: SimpleReverseProxy-openssl1.1.1f
repo: MarmadileManteater/SimpleReverseProxy
check_artifacts: false
search_artifacts: false
skip_unpack: false
if_no_artifact_found: fail
- name: Get the latest FT Cordova release
run: |
FT_DOWNLOAD_URL=$(curl --request GET --url "https://api.github.com/repos/MarmadileManteater/FreeTubeCordova/releases" --header "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" | jq '.[0].assets[1].browser_download_url')
curl -L --request GET --url ${FT_DOWNLOAD_URL:1:-1} --header "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -o ftc.zip
- name: 🀐 Unzip FreeTubeCordova artifact
run: |
unzip -qq ./ftc.zip -d ./artifacts/public/freetube
- name: Make hrefs in FTcordova absolute links
run: |
sed -i -e 's@href="@href="/freetube/@g' ./artifacts/public/freetube/index.html
sed -i -e 's@src="@src="/freetube/@g' ./artifacts/public/freetube/index.html
- name: ⬇ Download SvelteKitSite artifact
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: main.yml
workflow_conclusion: success
branch: development
path: .
name: MarmadileManteaterSvelteStatic
repo: MarmadileManteater/SvelteKitSite
check_artifacts: false
search_artifacts: false
skip_unpack: false
if_no_artifact_found: fail
- name: 🀐 Unzip SvelteKitSite artifact
uses: montudor/action-zip@v1
with:
args: unzip -qq static-adapter.zip -d ./artifacts/
- name: Rename artifact folder
run: |
sudo chown -R $(whoami) .
mv ./artifacts/static-adapter ./artifacts/public/sveltekitsite
cp -r ./artifacts/public/freetube ./artifacts/public/sveltekitsite/
- name: 🚚 Move data.json to artifact folder
run: |
mv ./marmadilemanteater.dev/data.json ./artifacts/
- name: 🀐 Zip up artifacts directory for 🏎faster uploads
uses: montudor/action-zip@v1
with:
args: zip -r artifacts.zip ./artifacts
- name: πŸ“¦ Publish artifact
uses: actions/upload-artifact@v3
with:
name: MarmadileManteater.dev
path: artifacts.zip
- name: πŸ— Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder'
- name: Add known hosts
run: ssh-keyscan -H ${{ secrets.LINODE_IP_ADDRESS }} >> ~/.ssh/known_hosts
- name: πŸš€ Deploy with scp
run: scp artifacts.zip ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }}:~/
- name: πŸͺ“ Kill any running tmux sessions on my linode
continue-on-error: true
run: |
ssh -t ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'tmux kill-session -tsimple-rust-site'
ssh -t ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'tmux kill-session -tsvelte-kit-site'
- name: 🀐 Unzip the artifacts on my linode
run: |
ssh -t ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'rm marmadilemanteater.dev -r'
ssh -t ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'unzip -qq artifacts.zip -d .'
ssh -t ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'mv artifacts marmadilemanteater.dev'
ssh -t ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'ln -s ~/marmadilemanteater.dev/public/freetube/ ~/marmadilemanteater.dev/public/sveltekitsite/freetube'
ssh -t ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'rm artifacts.zip'
- name: πŸ”“ Allow simple_rust_site to be executed
run: |
ssh -t ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'cd marmadilemanteater.dev && chmod +x simple_rust_site'
- name: ✨ Start tmux session for SimpleReverseProxy
run: |
ssh -tt ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} "tmux new -d -s simple-rust-site"
ssh -tt ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} "tmux send-keys -tsimple-rust-site 'cd marmadilemanteater.dev' Enter"
# this is a little hacky, but it is important to note I am avoiding accidentally storing the agent's password in `.bash_history` by putting a space before the commands
ssh -tt ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} " echo \"${{ secrets.SUDO_PASSWORD }}\" >> password.txt "
ssh -tt ${{ secrets.SSH_USER }}@${{ secrets.LINODE_IP_ADDRESS }} 'tmux send-keys -tsimple-rust-site " sudo -S <<< \"\$(cat ../password.txt)\" ./simple_rust_site ../fullchain.pem ../privkey.pem ./data.json" Enter && sleep 2s && rm password.txt'