diff --git a/.github/workflows/pr_deploy.yml b/.github/workflows/pr_deploy.yml new file mode 100644 index 0000000..be09321 --- /dev/null +++ b/.github/workflows/pr_deploy.yml @@ -0,0 +1,63 @@ +name: Deploy pull request + +on: pull_request + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + name: Build Development + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + build-args: | + BUILD_MODE=development + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + deploy-dev: + name: Deploy Development + runs-on: ubuntu-latest + needs: build-and-push-image + environment: + name: development + url: https://${{ github.event.repository.name }}__pr-${{ github.event.pull_request.number }}.dev.profcomff.com/ + steps: + - name: Deploy + run: | + curl -X 'POST' \ + 'https://ci.dev.profcomff.com/pr_run' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -H 'Authorization: ${{ secrets.CI_DYAKOVSPACE_MSK_TOKEN }}' \ + -d '{ + "repo_url": "${{ github.repository }}", + "git_ref": "${{ github.ref }}" + }' + diff --git a/.github/workflows/pr_test_deploy.yml b/.github/workflows/pr_lint.yml similarity index 94% rename from .github/workflows/pr_test_deploy.yml rename to .github/workflows/pr_lint.yml index 528ccc9..8caa55f 100644 --- a/.github/workflows/pr_test_deploy.yml +++ b/.github/workflows/pr_lint.yml @@ -1,4 +1,4 @@ -name: Review deployment +name: Lint pull request on: pull_request diff --git a/.github/workflows/pr_stop.yml b/.github/workflows/pr_stop.yml new file mode 100644 index 0000000..953cd10 --- /dev/null +++ b/.github/workflows/pr_stop.yml @@ -0,0 +1,31 @@ +name: Deploy pull request (stop) + +on: + pull_request: + types: [closed] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + stop-deployment-dev: + name: Deploy Development (stop) + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Stop deployment + run: | + curl -X 'POST' \ + 'https://ci.dev.profcomff.com/pr_stop' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -H 'Authorization: ${{ secrets.CI_DYAKOVSPACE_MSK_TOKEN }}' \ + -d '{ + "repo_url": "${{ github.repository }}", + "git_ref": "${{ github.ref }}" + }' +