name: release-tag on: push: branches: - main jobs: detect-changes: runs-on: ubuntu-latest outputs: bot: ${{ steps.filter.outputs.bot }} api: ${{ steps.filter.outputs.api }} steps: - name: Checkout code uses: actions/checkout@v4 - name: Check for changes uses: dorny/paths-filter@v2 id: filter with: filters: | bot: - 'apps/bot/**' - 'packages/**' api: - 'apps/api/**' - 'packages/**' build-and-deploy-bot: needs: detect-changes if: needs.detect-changes.outputs.bot == 'true' env: DOCKER_LATEST: latest runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Get Meta id: meta run: | echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT - name: Log in to Docker registry uses: docker/login-action@v3 with: registry: ${{ vars.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push bot uses: docker/build-push-action@v5 with: context: . file: ./apps/bot/Dockerfile push: true tags: | ${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-bot:${{ steps.meta.outputs.REPO_VERSION }} ${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-bot:${{ env.DOCKER_LATEST }} - name: Trigger Dokploy Bot Deployment run: | curl -X 'POST' \ 'https://${{ vars.DOKPLOY_DOMAIN }}/api/trpc/application.deploy' \ -H 'accept: application/json' \ -H 'x-api-key:${{ secrets.DOKPLOY_API_KEY }}' \ -H 'Content-Type: application/json' \ -d '{ "json":{ "applicationId": "${{ vars.DOKPLOY_BOT_APPLICATION_ID }}" } }' build-and-deploy-api: needs: detect-changes if: needs.detect-changes.outputs.api == 'true' env: DOCKER_LATEST: latest runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Get Meta id: meta run: | echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT - name: Log in to Docker registry uses: docker/login-action@v3 with: registry: ${{ vars.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push api uses: docker/build-push-action@v5 with: context: . file: ./apps/api/Dockerfile push: true tags: | ${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-api:${{ steps.meta.outputs.REPO_VERSION }} ${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-api:${{ env.DOCKER_LATEST }} - name: Trigger Dokploy API Deployment run: | curl -X 'POST' \ 'https://${{ vars.DOKPLOY_DOMAIN }}/api/trpc/application.deploy' \ -H 'accept: application/json' \ -H 'x-api-key:${{ secrets.DOKPLOY_API_KEY }}' \ -H 'Content-Type: application/json' \ -d '{ "json":{ "applicationId": "${{ vars.DOKPLOY_API_APPLICATION_ID }}" } }'