Merge pull request #6 from xerxes-openclaw/fix/allow-resubmission-in-… #2
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: Build & Deploy | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| build-and-push: | |
| name: Build & push images | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Compute lowercase image namespace | |
| id: image_vars | |
| shell: bash | |
| run: echo "owner_lc=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT" | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build & push API | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: apps/api/Dockerfile | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ steps.image_vars.outputs.owner_lc | |
| }}/ethsec-api:latest,${{ env.REGISTRY }}/${{ | |
| steps.image_vars.outputs.owner_lc }}/ethsec-api:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build & push Web | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: apps/web/Dockerfile | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ steps.image_vars.outputs.owner_lc | |
| }}/ethsec-web:latest,${{ env.REGISTRY }}/${{ | |
| steps.image_vars.outputs.owner_lc }}/ethsec-web:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| VITE_API_BASE_URL= | |
| VITE_BADGE_CONTRACT=${{ secrets.BADGE_CONTRACT }} | |
| VITE_CHAIN_ID=${{ secrets.CHAIN_ID }} | |
| VITE_RPC_URL=${{ secrets.RPC_URL }} | |
| VITE_WALLETCONNECT_PROJECT_ID=${{ secrets.VITE_WALLETCONNECT_PROJECT_ID }} | |
| VITE_ENCRYPTION_PUBLIC_KEY_HEX=${{ secrets.ENCRYPTION_PUBLIC_KEY_HEX }} | |
| deploy: | |
| name: Deploy to VPS | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Pull & restart stack | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USER }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| script: | | |
| cd ~/ethsec-voting-badge | |
| git pull --ff-only | |
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| docker compose -f docker-compose.yml -f docker-compose.prod.yml pull | |
| docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --force-recreate --remove-orphans | |
| docker image prune -f |