Deploy on Hosting #188
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 on Hosting | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ endsWith(github.ref, '/main') && 'production' || 'development' }} | |
env: | |
PUBLIC_DIRECTUS_URL: ${{ secrets.PUBLIC_DIRECTUS_URL }} | |
PUBLIC_DIRECTUS_PROJECT: ${{ secrets.PUBLIC_DIRECTUS_PROJECT }} | |
DIRECTUS_PROJECT: "etherna" | |
DIRECTUS_TOKEN: ${{ secrets.DIRECTUS_TOKEN }} | |
DISABLE_SOURCEMAP: "true" | |
SITE_URL: "https://info.etherna.io" | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.11.0 | |
with: | |
access_token: ${{ github.token }} | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
architecture: "x64" | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build site | |
run: pnpm build | |
- name: Cache build artifacts | |
uses: actions/cache@v3 | |
with: | |
path: "**/dist" | |
key: build-artifacts-${{ github.sha }} | |
publish_host: | |
name: Publish to Host | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: production | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Restore build artifacts | |
uses: actions/cache@v3 | |
with: | |
path: "**/dist" | |
key: build-artifacts-${{ github.sha }} | |
- name: Upload to Host | |
uses: sebastianpopp/ftp-action@releases/v2 | |
with: | |
host: ${{ secrets.FTP_HOST }} | |
user: ${{ secrets.FTP_USERNAME }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
localDir: dist | |
remoteDir: ${{ secrets.FTP_REMOTE_DIR }} | |
options: "--delete -X cgi-bin/ -X .well-known/" | |
publish_swarm: | |
name: Publish on Swarm | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: production | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Restore build artifacts | |
uses: actions/cache@v3 | |
with: | |
path: "**/dist" | |
key: build-artifacts-${{ github.sha }} | |
- name: Upload to swarm | |
uses: Etherna/swarm-upload-action@2.0.0 | |
with: | |
gateway: https://gateway.etherna.io | |
localRoot: dist | |
defaultPath: index.html | |
ethernaApiKey: ${{ secrets.ETHERNA_API_KEY }} | |
batchId: ${{ secrets.BATCH_ID }} | |
feedName: EthernaWebsite | |
feedType: epoch |