az-swa-deploy #73
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: ssg | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 4 * * *" | |
env: | |
SSHSTATS_BACKEND: "https://monkfish-app-ss3gb.ondigitalocean.app" | |
SSHSTATS_NUXT_PUBLIC_BASE_URL: "http://localhost:65000/fe/data" | |
jobs: | |
generate-website: | |
runs-on: ubuntu-22.04 | |
services: | |
data-server: | |
image: nginx:1.27.1 | |
ports: | |
- 65000:80 | |
volumes: | |
- ${{ github.workspace }}:/usr/share/nginx/html # TODO: You need to bind mount to an existing folder ? | |
steps: | |
- name: checkout frontend repo | |
uses: actions/checkout@v4 | |
- name: unpack nodenames | |
run: | | |
SSHSTATS_NODENAMES=$(jq -r '.[]' fe/assets/nodenames.json | tr '\n' ' ') | |
echo "SSHSTATS_NODENAMES=$SSHSTATS_NODENAMES" >> "$GITHUB_ENV" | |
- name: download attempts data | |
run: | | |
for nodename in $SSHSTATS_NODENAMES; do | |
echo "Downloading $nodename.json" | |
sleep .5 | |
curl -v \ | |
-H "${{ secrets.SSHSTATS_API_AUTH_KEY }}: ${{ secrets.SSHSTATS_API_AUTH_VALUE }}" \ | |
--output-dir fe/data/logins \ | |
-o "$nodename.json" \ | |
--fail-with-body \ | |
"${{ env.SSHSTATS_BACKEND }}/stats/$nodename" | |
done | |
- name: store attempts data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: attempts-data | |
path: | | |
fe/data/logins/*.json | |
- name: configure nuxt | |
run: | | |
echo "NUXT_PUBLIC_BASE_URL=${{ env.SSHSTATS_NUXT_PUBLIC_BASE_URL }}" >> fe/.env | |
- name: setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "22.6.0" | |
- name: npm ci | |
working-directory: ./fe | |
run: | | |
npm ci | |
- name: nuxt generate | |
working-directory: ./fe | |
run: | | |
npm run generate | |
- name: docker login | |
uses: docker/login-action@v3 | |
with: | |
registry: registry.digitalocean.com/edu | |
username: ${{ secrets.SSHSTATS_DO_REGISTRY_USERNAME }} | |
password: ${{ secrets.SSHSTATS_DO_REGISTRY_TOKEN }} | |
- name: docker build | |
uses: docker/build-push-action@v6 | |
with: | |
file: ./fe/Dockerfile | |
context: ./fe | |
push: true | |
tags: registry.digitalocean.com/edu/sshstats/fe:latest |