actions-vps-mirror/.github/workflows/runglobal.yml

101 lines
3.6 KiB
YAML
Raw Permalink Normal View History

2024-11-02 23:36:38 -04:00
name: Run
2024-10-03 23:44:27 -04:00
on:
workflow_dispatch:
inputs:
runNext:
description: 'Should run next'
required: true
default: true
type: boolean
2024-10-23 01:09:55 -04:00
name:
description: 'Machine name'
required: true
default: 'global'
type: string
2024-10-05 21:11:19 -04:00
oldTailscaleHostname:
description: 'Old Tailscale Hostname (not needed)'
required: false
default: ''
type: string
2024-10-03 23:44:27 -04:00
permissions: write-all
env:
2024-10-16 06:07:14 -04:00
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
2024-10-03 23:44:27 -04:00
jobs:
custom:
runs-on: ubuntu-24.04
2024-10-03 23:44:27 -04:00
steps:
- name: Setup Python (for use with Page flying on a Kite)
uses: actions/setup-python@v5
2024-10-03 23:44:27 -04:00
with:
python-version: '3.11'
- name: Setup Java 21 (Eclipse Temurin) // !!! broken, does nothing
2024-10-14 22:31:28 -04:00
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Installs some stuff
2024-10-03 23:44:27 -04:00
run: |
sudo apt update -y
2024-10-16 06:02:12 -04:00
sudo apt install mosh -y
2024-10-10 07:10:30 -04:00
wget -O /tmp/mega.deb https://mega.nz/linux/repo/xUbuntu_24.04/amd64/megacmd-xUbuntu_24.04_amd64.deb
sudo apt install -y "/tmp/mega.deb"
2024-10-03 23:44:27 -04:00
curl -fsSL https://tailscale.com/install.sh | sh
2024-10-06 02:03:50 -04:00
npm install -g serve
- name: Change Security Word
run: echo "$(whoami):password1!" | sudo chpasswd
- name: Start the scale to measure the weight of this server
2024-10-23 01:09:55 -04:00
run: sudo tailscale up --hostname="$(if ${{ inputs.runNext }}; then echo ${{ inputs.name }}; else echo manual-${{ inputs.name }}-$(TZ=Asia/Tokyo date +%H-%M-%S); fi)" --advertise-exit-node --ssh --authkey ${{ secrets.TAILSCALE_KEY }}
- name: Fix the PS having no colors
# the problem is actually the bash_profile on runner's home
# but i was too lazy and simply did this (works too)
run: |
2024-10-03 23:44:27 -04:00
sed -i 's/unset .*//g' $HOME/.bashrc
sed -i 's/#force_color_prompt/force_color_prompt/g' $HOME/.bashrc
echo 'source $HOME/.bashrc' | sudo tee -a /etc/profile
- name: Kill something :D
run: sudo pkill provjobd
- name: Create the global data directory and set permissions
2024-10-03 23:44:27 -04:00
run: |
2024-10-07 07:24:46 -04:00
sudo mkdir /mnt/globalData
2024-10-07 21:41:32 -04:00
sudo chown $(whoami) /mnt/globalData/
2024-10-11 22:49:59 -04:00
- name: Dump GitHub token, GitHub context and other environment variables to the home directory (useful for debugging purposes)
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: |
echo "$GITHUB_CONTEXT" >> ~/github_context.txt
echo "$GH_TOKEN" > ~/gh_token.txt
env >> ~/env.txt
2024-10-11 22:49:59 -04:00
- name: Get files from old runtime (if exists)
if: ${{ inputs.oldTailscaleHostname != '' }}
2024-10-03 23:44:27 -04:00
run: |
2024-10-11 22:49:59 -04:00
cd /mnt/globalData
aria2c -x 16 -j 16 -s 16 http://${{ inputs.oldTailscaleHostname }}:5000/archive.tar.gz
2024-10-11 22:49:59 -04:00
tar xf archive.tar.gz
rm -rf archive.tar.gz
- name: Run post-install script (if exists)
2024-10-20 19:52:27 -04:00
working-directory: /mnt/globalData
run: |
2024-10-20 19:52:27 -04:00
if [ -f toBackup/postinstall.sh ]; then
. toBackup/postinstall.sh &
fi
2024-10-11 22:49:59 -04:00
- name: Run the long-lived process
working-directory: /mnt/globalData
run: |
2024-11-02 23:36:38 -04:00
wget https://raw.githubusercontent.com/Frail7487Real/laughing-spork/refs/heads/master/checkTime.js
2024-11-02 23:36:38 -04:00
wget https://raw.githubusercontent.com/Frail7487Real/laughing-spork/refs/heads/master/loop.sh
2024-10-04 00:35:56 -04:00
chmod +x loop.sh
2024-10-11 22:49:59 -04:00
# what an argument mess
2024-11-02 23:36:38 -04:00
bash loop.sh ${{ inputs.runNext }} $GH_TOKEN laughing-spork runglobal.yml master ${{ inputs.name }} $WEBHOOK_URL true ${{ inputs.oldTailscaleHostname }}