Deploy Static Files to Server #5
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: "Deploy Static Files to Server" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: | |
name: FTP | |
steps: | |
- name: "Checking Out" | |
uses: actions/checkout@v4.1.4 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: | | |
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- name: "Caching yarn" | |
uses: actions/cache@v4.0.2 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: "Caching build" | |
uses: actions/cache@v4.0.2 | |
with: | |
path: | | |
~/.npm | |
${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Setting Up Node.js | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version: "22" | |
cache: "yarn" | |
- name: Installing dependencies | |
run: yarn | |
- name: Generating Static Files | |
run: yarn build | |
- name: Deploy to Server | |
uses: SamKirkland/FTP-Deploy-Action@v4.3.5 | |
with: | |
server: ${{ secrets.FTP_SERVER }} | |
port: ${{ secrets.FTP_PORT }} | |
username: ${{ secrets.FTP_UNAME }} | |
password: ${{ secrets.FTP_PASS }} | |
protocol: ${{ secrets.FTP_PROTOCOL }} | |
local-dir: ./opensource/minomax/ | |
server-dir: opensource/minomax/ | |
security: strict |