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 Frontend | |
| on: | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - "apps/frontend/package.json" | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version_changed: ${{ steps.check.outputs.changed }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check if version changed | |
| id: check | |
| run: | | |
| OLD_VERSION=$(git show HEAD^:apps/frontend/package.json | jq -r '.version') | |
| NEW_VERSION=$(jq -r '.version' apps/frontend/package.json) | |
| if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Version changed: $OLD_VERSION -> $NEW_VERSION" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "Version unchanged: $NEW_VERSION" | |
| fi | |
| amd64: | |
| needs: check-version | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Login to registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ secrets.REGISTRY }} | |
| username: ${{ secrets.REGISTRY_USER }} | |
| password: ${{ secrets.REGISTRY_PASSWORD }} | |
| - name: Build image and push to registry | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: ./apps/frontend/Dockerfile | |
| platforms: linux/amd64 | |
| build-args: | | |
| VITE_BASE=${{ vars.VITE_BASE || '/' }} | |
| VITE_MAPBOX_TOKEN=${{ secrets.VITE_MAPBOX_TOKEN }} | |
| VITE_SERVER_URL=${{ vars.VITE_SERVER_URL }} | |
| VITE_SITE_URL=${{ secrets.VITE_SITE_URL }} | |
| push: true | |
| tags: ${{ secrets.REGISTRY }}/${{ secrets.FRONTEND_IMAGE_NAME }}:latest | |
| - name: Trigger deploy via Dokploy API | |
| run: | | |
| curl -X POST "${{ secrets.DOKPLOY_API_URL }}/api/application.deploy" \ | |
| -H "accept: application/json" \ | |
| -H "Content-Type: application/json" \ | |
| -H "x-api-key: ${{ secrets.DOKPLOY_API_KEY }}" \ | |
| -d "{\"applicationId\":\"${{ secrets.DOKPLOY_FRONTEND_APP_ID }}\"}" |