frontend: switch to rsbuild (and pnpm) #61
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: pipe | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
DOCKERHUB_USERNAME: veetik | |
DOCKER_IMAGE_BACKEND: veetik/tasks-backend | |
DOCKER_IMAGE_FRONTEND: veetik/tasks-frontend | |
FRONT_API_URL: https://tasks-api.veetik.com | |
FRONT_VAPID_PUBLIC_KEY: BMvRTtdBaxw8nWOkVbBOH_mC7sPHTkgVbbtrYqEek05-iupcxgkLUksERHvFsBIE5xytDaNzxeuLHTLu8FC-O-k | |
FRONT_DIR: ./frontend | |
BACK_DIR: ./backend | |
jobs: | |
determine_changes: | |
runs-on: ubuntu-latest | |
outputs: | |
backend: ${{ steps.changes.outputs.backend }} | |
frontend: ${{ steps.changes.outputs.frontend }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd | |
id: changes | |
with: | |
filters: | | |
backend: | |
- 'backend/**' | |
frontend: | |
- 'frontend/**' | |
check_backend: | |
runs-on: ubuntu-latest | |
needs: [determine_changes] | |
if: needs.determine_changes.outputs.backend == 'true' | |
defaults: | |
run: | |
working-directory: ${{ env.BACK_DIR }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc | |
with: | |
components: rustfmt | |
- name: check formatting | |
run: cargo fmt --check | |
build_and_push_backend_image: | |
runs-on: ubuntu-latest | |
needs: [check_backend] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: login to docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_IMAGE_BACKEND }} | |
tags: | | |
type=sha | |
type=ref,event=branch | |
type=ref,event=pr | |
- name: build and push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
context: ${{ env.BACK_DIR }} | |
platforms: linux/amd64 | |
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_BACKEND }}:buildcache | |
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE_BACKEND }}:buildcache,mode=max | |
deploy_backend: | |
runs-on: ubuntu-latest | |
needs: [build_and_push_backend_image] | |
if: github.event_name != 'pull_request' | |
environment: prod | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: login to docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_IMAGE_BACKEND }} | |
tags: prod | |
- name: build and push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
context: ${{ env.BACK_DIR }} | |
platforms: linux/amd64 | |
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_BACKEND }}:buildcache | |
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE_BACKEND }}:buildcache,mode=max | |
- name: update deployment | |
uses: appleboy/ssh-action@029f5b4aeeeb58fdfe1410a5d17f967dacf36262 | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
script: | | |
cd ~/tasks && \ | |
docker rollout -f ./docker-compose.yml backend | |
check_frontend: | |
runs-on: ubuntu-latest | |
needs: [determine_changes] | |
if: needs.determine_changes.outputs.frontend == 'true' | |
defaults: | |
run: | |
working-directory: ${{ env.FRONT_DIR }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
name: install pnpm | |
with: | |
version: 9 | |
run_install: false | |
- name: install node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
cache-dependency-path: './frontend/pnpm-lock.yaml' | |
- name: get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: install deps | |
run: pnpm install | |
- name: check formatting | |
run: pnpm run formatcheck | |
- name: typecheck | |
run: pnpm run typecheck | |
- name: lint | |
run: pnpm run lint | |
- name: build | |
run: pnpm run build | |
build_and_push_frontend_image: | |
runs-on: ubuntu-latest | |
needs: [check_frontend] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: login to docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_IMAGE_FRONTEND }} | |
tags: | | |
type=sha | |
type=ref,event=branch | |
type=ref,event=pr | |
- name: build and push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
context: ${{ env.FRONT_DIR }} | |
platforms: linux/amd64 | |
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_FRONTEND }}:buildcache | |
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE_FRONTEND }}:buildcache,mode=max | |
build-args: | | |
API_URL=${{ env.FRONT_API_URL }} | |
VAPID_PUBLIC_KEY=${{ env.FRONT_VAPID_PUBLIC_KEY }} | |
deploy_frontend: | |
runs-on: ubuntu-latest | |
needs: [build_and_push_frontend_image] | |
if: github.event_name != 'pull_request' | |
environment: prod | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: login to docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_IMAGE_FRONTEND }} | |
tags: prod | |
- name: build and push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
context: ${{ env.FRONT_DIR }} | |
platforms: linux/amd64 | |
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_FRONTEND }}:buildcache | |
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE_FRONTEND }}:buildcache,mode=max | |
build-args: | | |
API_URL=${{ env.FRONT_API_URL }} | |
VAPID_PUBLIC_KEY=${{ env.FRONT_VAPID_PUBLIC_KEY }} | |
- name: update deployment | |
uses: appleboy/ssh-action@029f5b4aeeeb58fdfe1410a5d17f967dacf36262 | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
script: | | |
cd ~/tasks && \ | |
docker rollout -f ./docker-compose.yml frontend | |