This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
Ajustes #11
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 Preview to Vercel | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- main | |
- develop | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: npm | |
cache-dependency-path: '**/package-lock.json' | |
- name: Install dependencies | |
run: npm install --no-audit --no-fund | |
- name: Deploy to Vercel (Preview) | |
id: deploy | |
uses: amondnet/vercel-action@v25 | |
with: | |
vercel-token: ${{ secrets.VERCEL_TOKEN }} | |
github-token: ${{ secrets.GH_TOKEN }} | |
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} | |
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} | |
scope: ${{ secrets.VERCEL_ORG_ID }} | |
working-directory: ./ | |
github-comment: true | |
- name: Print preview URL | |
run: | | |
echo ${{ steps.deploy.outputs.preview-url }} | |
- name: Create issue if deploy fails | |
if: failure() | |
uses: JasonEtco/create-an-issue@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
ACTION_TYPE: 'Deploy' | |
URL_ACTION_RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
BRANCH: ${{ github.ref }} | |
with: | |
assignees: ${{ github.event.sender.login }} | |
- name: Comment on PR if failed | |
if: failure() | |
uses: unsplash/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
with: | |
msg: 'Ocurrió un error al desplegar la rama. Por favor revisa los errores y toma las medidas necesarias. Action Run: [Action](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).' | |
- name: Comment on PR | |
uses: unsplash/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
with: | |
msg: 'El despliegue del Preview ha sido exitoso :+1: :thumbsup:.' |