V
V
Victor L2021-03-15 21:14:33
GitHub
Victor L, 2021-03-15 21:14:33

How to deploy when merging with a master?

Greetings, I can’t properly organize the deployment so that it happens only when merging with the master. Now, even with any push of a branch to a remote repository, a deployment occurs.
Can you please tell me how to organize it? (a project on nuxtjs hosting is normal) now there is this:

name: Deploy

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]

    steps:
    - uses: actions/[email protected]
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/[email protected]
      with:
        node-version: ${{ matrix.node-version }}
    # Setup key
    - run: set -eu
    - run: mkdir "$HOME/.ssh"
    - run: echo "${{ secrets.key }}" > "$HOME/.ssh/key"
    - run: chmod 600 "$HOME/.ssh/key"
    - name: npm install, generate
      run: |
           npm install
           npm run generate
    # Deploy
    - run: cd dist && rsync -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" --archive --compress --delete . [email protected]:/home/u/u/demo/public_html/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Velichko, 2021-04-01
@Fzero0

Remove if you do not want the script to work when pushing to the master

push:
    branches: [ master ]

This is the event guide https://docs.github.com/en/actions/reference/event...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question