Skip to content

Instantly share code, notes, and snippets.

@alanleyva
Created January 22, 2021 00:17
Show Gist options
  • Save alanleyva/292f0f80f9d487d748c225351a011c51 to your computer and use it in GitHub Desktop.
Save alanleyva/292f0f80f9d487d748c225351a011c51 to your computer and use it in GitHub Desktop.
Archivo de GitHub actions con notificaciones de Slack
name: Build and Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@main
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build
- name: Archive Production Artifact
uses: actions/upload-artifact@master
with:
name: build
path: build
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: build
path: build
- name: Copying files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: user_name
key: ${{ secrets.SSH_KEY }}
# rm: true
# port: 22 //puedes especificar el puerto si es necesario para tu servidor
source: "build/"
target: "${{ secrets.REMOTE_DIR }}"
- name: Send Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: deploys
SLACK_COLOR: "#9e2a2b"
#SLACK_ICON: https://someurl.com/logo.png
SLACK_MESSAGE: "Failed execution on production build"
SLACK_TITLE: Failed execution
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment