Test Release #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
release: | |
types: [created] | |
permissions: | |
contents: write | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
# Check out the repository | |
- name: Check out the code | |
uses: actions/checkout@v3 | |
# Set up Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' # Use the Node.js version your project requires | |
# Install dependencies | |
- name: Install dependencies | |
run: | | |
npm install --global yarn | |
yarn install | |
# Build the project | |
- name: Build the project | |
run: npm run build | |
# Zip the project | |
- name: Build the project | |
run: zip -r build.zip build/ | |
# Set up the GitHub CLI | |
- name: Install GitHub CLI | |
run: sudo apt-get install gh | |
# Upload files to release | |
- name: Upload ZIP file to Release | |
run: gh release upload "${{ github.event.release.tag_name }}" "build.zip" --clobber | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Set up SSH KEY | |
- name: Set up SSH key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_KEY }}" > ssh_key | |
chmod 600 ssh_key | |
# Add the server to known hosts to avoid prompt | |
- name: Add server to known_hosts | |
run: | | |
ssh-keyscan -H "${{ secrets.SSH_HOST }}" >> ~/.ssh/known_hosts | |
# SSH into the server and run commands | |
- name: SSH and Execute Script | |
env: | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
SERVER_USER: ${{ secrets.SSH_USERNAME }} | |
SERVER_HOST: ${{ secrets.SSH_HOST }} | |
run: | | |
scp -i ~/.ssh/ssh_key -o StrictHostKeyChecking=no build.zip $SERVER_USER@$SERVER_HOST:~/latest_build.zip |