|
| 1 | +name: embedded-chat |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + paths: |
| 7 | + - 'packages/embedded-chat/**' |
| 8 | + branches: |
| 9 | + - main |
| 10 | + tags: |
| 11 | + - "v*.*.*" |
| 12 | + pull_request: |
| 13 | + paths: |
| 14 | + - 'packages/embedded-chat/**' |
| 15 | + branches: |
| 16 | + - main |
| 17 | + |
| 18 | +jobs: |
| 19 | + lint: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + name: Check for Linting Errors |
| 22 | + defaults: |
| 23 | + run: |
| 24 | + working-directory: packages/embedded-chat |
| 25 | + steps: |
| 26 | + - name: Checkout Repository |
| 27 | + uses: actions/checkout@v3 |
| 28 | + with: |
| 29 | + ref: ${{ github.event.pull_request.head.ref }} |
| 30 | + |
| 31 | + - name: Setup NodeJS |
| 32 | + uses: actions/setup-node@v3 |
| 33 | + with: |
| 34 | + node-version: 22 |
| 35 | + |
| 36 | + - name: NPM Install |
| 37 | + run: npm install --only=dev |
| 38 | + shell: bash |
| 39 | + |
| 40 | + - name: Check for Linting Issues |
| 41 | + run: npm run prettier |
| 42 | + |
| 43 | + build: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + name: Build Code |
| 46 | + defaults: |
| 47 | + run: |
| 48 | + working-directory: packages/embedded-chat |
| 49 | + steps: |
| 50 | + - name: Checkout Repository |
| 51 | + uses: actions/checkout@v3 |
| 52 | + |
| 53 | + - name: Setup NodeJS |
| 54 | + uses: actions/setup-node@v3 |
| 55 | + with: |
| 56 | + node-version: 22 |
| 57 | + |
| 58 | + - name: NPM Install |
| 59 | + run: npm install |
| 60 | + shell: bash |
| 61 | + |
| 62 | + - name: Build |
| 63 | + run: npm run build |
| 64 | + |
| 65 | + docker: |
| 66 | + name: Docker Build and Push |
| 67 | + runs-on: ubuntu-latest |
| 68 | + defaults: |
| 69 | + run: |
| 70 | + working-directory: packages/embedded-chat |
| 71 | + steps: |
| 72 | + - uses: docker/setup-qemu-action@v2 |
| 73 | + - uses: docker/setup-buildx-action@v2 |
| 74 | + |
| 75 | + - name: Checkout repository |
| 76 | + uses: actions/checkout@v3 |
| 77 | + |
| 78 | + - name: Docker Tags |
| 79 | + id: meta |
| 80 | + uses: docker/metadata-action@v4 |
| 81 | + with: |
| 82 | + images: | |
| 83 | + hicsail/preaa-embedded-chat |
| 84 | + tags: | |
| 85 | + type=ref,event=branch |
| 86 | + type=semver,pattern={{version}} |
| 87 | + type=semver,pattern={{major}} |
| 88 | + type=semver,pattern={{major}}.{{minor}} |
| 89 | +
|
| 90 | + - name: Login to Docker Hub |
| 91 | + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') |
| 92 | + uses: docker/login-action@v2 |
| 93 | + with: |
| 94 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 95 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 96 | + |
| 97 | + - name: Build & Push Docker Build |
| 98 | + uses: docker/build-push-action@v4 |
| 99 | + with: |
| 100 | + push: ${{ github.event_name != 'pull_request' }} |
| 101 | + context: ./packages/embedded-chat |
| 102 | + file: ./packages/embedded-chat/Dockerfile |
| 103 | + tags: ${{ steps.meta.outputs.tags }} |
| 104 | + labels: ${{ steps.meta.outputs.labels }} |
| 105 | + cache-from: type=gha,scope=gateway |
| 106 | + cache-to: type=gha,mode=max,scope=gateway |
| 107 | + build-args: | |
| 108 | + VITE_BACKEND_BASE_URL=${{ secrets.HELPER_BACKEND_URL }} |
| 109 | +
|
| 110 | + deployment: |
| 111 | + runs-on: ubuntu-latest |
| 112 | + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') |
| 113 | + needs: [docker] |
| 114 | + steps: |
| 115 | + - name: Push to Staging |
| 116 | + uses: fjogeleit/http-request-action@v1 |
| 117 | + with: |
| 118 | + method: "POST" |
| 119 | + url: ${{ secrets.PORTAINER_WEBHOOK }} |
| 120 | + preventFailureOnNoResponse: true |
0 commit comments