Fail swap out gracefully when we have no on-chain funds to pay the contract #550
This file contains hidden or 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: Backend/Frontend CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - "master" | |
| tags: | |
| - "*" | |
| paths-ignore: | |
| - "daemon/**" | |
| - ".justfile" | |
| - "README.md" | |
| pull_request: | |
| branches: | |
| - master | |
| concurrency: | |
| # Cancel any previous workflows if they are from a PR or push. | |
| group: ${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME_FRONTEND: ${{ github.repository }}-swap-frontend | |
| IMAGE_NAME_BACKEND: ${{ github.repository }}-server-backend | |
| jobs: | |
| code-quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check code formatting | |
| run: npm run format:check | |
| - name: Check linting | |
| run: npm run lint | |
| integration-testing: | |
| runs-on: 40acres | |
| needs: code-quality | |
| permissions: | |
| contents: read | |
| packages: read | |
| services: | |
| docker: | |
| image: docker:dind | |
| options: --privileged --shm-size=2g | |
| volumes: | |
| - /var/run/docker.sock:/var/run/docker.sock:ro | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check if the integrations tests should be run | |
| uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 | |
| id: changed-files | |
| with: | |
| files: | | |
| server-backend/** | |
| shared/** | |
| swap-frontend/** | |
| docker/** | |
| - name: Setup Node.js | |
| if: steps.changed-files.outputs.any_modified == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies | |
| if: steps.changed-files.outputs.any_modified == 'true' | |
| run: npm ci | |
| - name: Build shared | |
| if: steps.changed-files.outputs.any_modified == 'true' | |
| working-directory: shared | |
| run: npm run build | |
| - name: Run tests | |
| if: steps.changed-files.outputs.any_modified == 'true' | |
| working-directory: server-backend | |
| run: npm test | |
| build: | |
| # Run this only when we are merging to :master and run without push the result during PRs | |
| if: | | |
| github.ref == 'refs/heads/master' || | |
| startsWith(github.ref, 'refs/tags/')|| | |
| github.event_name == 'pull_request' | |
| needs: [code-quality, integration-testing] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log into the Container registry | |
| uses: docker/login-action@v3.4.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta-fe | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_FRONTEND }} | |
| tags: | | |
| type=schedule | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=ref,event=pr | |
| type=raw,event=push,value=${{ github.ref_name }}-${{github.run_number}}-{{sha}} | |
| type=raw,event=push,value=${{ github.ref_name }}-${{github.run_number}} | |
| labels: | | |
| commit=${{ github.sha }} | |
| actions_run=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| - name: Build the frontend Docker image and push it to the registry if it's not a PR. | |
| id: build-and-push-frontend | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: swap-frontend/docker/Dockerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| platforms: linux/amd64 | |
| provenance: false | |
| tags: ${{ steps.meta-fe.outputs.tags }} | |
| labels: ${{ steps.meta-fe.outputs.labels }} | |
| - name: Docker meta | |
| id: meta-be | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BACKEND }} | |
| tags: | | |
| type=schedule | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=ref,event=pr | |
| type=raw,event=push,value=${{ github.ref_name }}-${{github.run_number}}-{{sha}} | |
| type=raw,event=push,value=${{ github.ref_name }}-${{github.run_number}} | |
| labels: | | |
| commit=${{ github.sha }} | |
| actions_run=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| - name: Build the backend Docker image and push it to the registry if it's not a PR. | |
| id: build-and-push-backend | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: server-backend/docker/Dockerfile | |
| # Only push the image if this is not a PR. | |
| push: ${{ github.event_name != 'pull_request' }} | |
| platforms: linux/amd64 | |
| provenance: false | |
| tags: ${{ steps.meta-be.outputs.tags }} | |
| labels: ${{ steps.meta-be.outputs.labels }} |