Merge pull request #564 from project-violet/dependabot/npm_and_yarn/v… #12
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: Server CD | |
on: | |
push: | |
branches: | |
- "dev" | |
workflow_dispatch: | |
jobs: | |
server-changes: | |
runs-on: ubuntu-latest | |
# Required permissions | |
permissions: | |
pull-requests: read | |
# Set job outputs to values from filter step | |
outputs: | |
src: ${{ steps.filter.outputs.src }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }} | |
# For pull requests it's not necessary to checkout the code | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
src: | |
- ".github/workflows/server-cd.yml" | |
- "violet-server/**" | |
deploy-by-docker: | |
needs: server-changes | |
if: ${{ needs.app-changes.outputs.src == 'true' || github.event_name != 'push' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: master | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: "{{defaultContext}}:violet-server" | |
push: true | |
tags: violetdev/violet:latest | |
- name: Diploy | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: ${{ secrets.WEBHOOK_URL }} | |
method: "POST" | |
timeout: 60000 | |
- name: CD Success | |
if: success() | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
title: "Success Deploy!" | |
color: 0x28e1ff | |
nodetail: true | |
description: | | |
Commit: [${{ github.event.head_commit.message }}](https://github.com/project-violet/violet-server/commit/${{ github.sha }}) | |
CI Log: [${{ github.ref }} / ${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
- name: CD Fail | |
if: failure() | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
title: "Failed to Deploy" | |
nodetail: true | |
color: 0xff9300 | |
content: "<@614104830738169877>" | |
description: | | |
Commit: [${{ github.event.head_commit.message }}](https://github.com/project-violet/violet-server/commit/${{ github.sha }}) | |
CI Log: [${{ github.ref }} / ${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |