Build & Deploy #101
Workflow file for this run
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 & Deploy | |
| on: | |
| push: | |
| branches: [dev] | |
| workflow_call: | |
| inputs: | |
| env: | |
| required: true | |
| type: string | |
| workflow_dispatch: | |
| inputs: | |
| env: | |
| description: "Environment to deploy to" | |
| required: true | |
| default: "dev" | |
| type: choice | |
| options: | |
| - dev | |
| jobs: | |
| push_to_registry: | |
| name: Push Docker image to GitHub Packages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v2 | |
| with: | |
| push: true | |
| tags: ghcr.io/unity-developer-community/udc-bot-dev:latest | |
| restart: | |
| name: Restart Bot | |
| needs: push_to_registry | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: ${{ inputs.env }} | |
| steps: | |
| - name: Run commands in SSH | |
| uses: appleboy/ssh-action@master | |
| with: | |
| script: | | |
| cd ${{ vars.SERVER_BUILD_DIR }} | |
| docker compose pull | |
| docker compose up -d | |
| host: ${{ vars.SERVER_IP }} | |
| port: ${{ vars.SERVER_PORT }} | |
| username: ${{ vars.SERVER_USER }} | |
| password: ${{ secrets.SERVER_PASSWORD }} | |
| - name: Discord notification | |
| env: | |
| DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
| uses: Ilshidur/action-discord@master | |
| with: | |
| args: Bot has been deployment to Test Server successfully. |