[IN-31] ci: add needed actions #2
Workflow file for this run
This file contains 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: Deploy PR Preview | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and push to ${{ github.event.repository.name }}-dev | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./infrastructure/preview.Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}-dev:preview-${{ github.event.number }}-${{ github.event.pull_request.head.sha }} | |
add_preview_label: | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions-ecosystem/action-add-labels@v1 | |
with: | |
labels: | | |
preview | |
dispatch_update_deployment: | |
needs: add_preview_label | |
runs-on: ubuntu-latest | |
if: ${{ contains(github.event.pull_request.labels.*.name, 'deployed') }} | |
steps: | |
- name: Dispatch Update Preview Repository Command | |
uses: myrotvorets/[email protected] | |
with: | |
token: ${{ secrets.PAT }} | |
repo: internxt/environments | |
type: update-preview-command | |
payload: | | |
{ | |
"github": { | |
"payload": { | |
"repository": { | |
"name": "${{ github.event.repository.name }}", | |
"full_name": "${{ github.event.repository.full_name }}" | |
}, | |
"issue": { | |
"number": ${{ github.event.number }}, | |
"labels": ${{ toJSON(github.event.pull_request.labels) }} | |
} | |
} | |
}, | |
"slash_command": { | |
"args": { | |
"named": { | |
"deployment": "${{ github.event.repository.name }}", | |
"tag": "preview-${{ github.event.number }}-${{ github.event.pull_request.head.sha }}", | |
"imageSuffix": "-dev" | |
} | |
} | |
} | |
} | |
dispatch_check_deployment: | |
needs: add_preview_label | |
runs-on: ubuntu-latest | |
steps: | |
- name: Dispatch Check Preview Repository Command | |
uses: myrotvorets/[email protected] | |
with: | |
token: ${{ secrets.PAT }} | |
repo: internxt/environments | |
type: check-preview-command | |
payload: | | |
{ | |
"github": { | |
"payload": { | |
"repository": { | |
"name": "${{ github.event.repository.name }}", | |
"full_name": "${{ github.event.repository.full_name }}", | |
"html_url": "${{ github.event.repository.html_url }}" | |
}, | |
"issue": { | |
"number": ${{ github.event.number }}, | |
"labels": ${{ toJSON(github.event.pull_request.labels) }}, | |
"pull_request": { | |
"html_url": "${{ github.event.pull_request.html_url }}" | |
} | |
} | |
} | |
}, | |
"slash_command": { | |
"args": { | |
"named": { | |
"notify": "true" | |
} | |
} | |
} | |
} |