GitHub Action --> Deploy NodeJS application using workflow. -- Please help me

DevOps_Boy

Active member
  • Jul 28, 2023
    238
    120
    43
    මචන් මම github action වලින් pipeline එකක් ලිව්වා nodejs application එකක් බිල්ඩ් කරලා aws තියන සර්වර් එකේ /var/www/html/ folder එකට ඒ බිල්ඩ් වෙච්ච ෆයිල් ටික කොපි කරන්න. application එක build උනා.ඒත් aws server එකට කොපි කරද්දි අවුලක් එනවා. මම aws server eke ssh-keygen -t rsa වලින් පබ්ලික් කී එකක් github එකේ secret ස්ටොරෙ කරලා pipeline eke demma. eth copy වෙද්දි error එකක් එන්ව. මෙකේ අවුල මොකද්ද?මම මේකට ජිට් හබ් සර්වර් එකමයි යූස් කලේ කෝඩ් එක බිල්ඩ් කරන්න.


    YAML:
    name: Deployment QA UI
    on: push
    jobs:
        Get_code:
            runs-on: ubuntu-latest
            steps:
                - name: Get code
                  uses: actions/checkout@v4
                - name: Install NodeJS
                  uses: actions/setup-node@v3
                  with:
                    node-version: 10
                - name: Install dependancies
                  run: NODE_OPTIONS=--max_old_space_size=4096 npm install
                - name: Check Nodejs
                  run: npx browserslist@latest --update-db
                - name: Build project
                  run: NODE_OPTIONS=--max_old_space_size=4096 npm run build
                - name: Go to build folder
                  run: |
                    cd /home/runner/work/simple_app/simple_app/build/
                    scp -i ${{ secrets.SSH_PRIVATE_KEY }} -r * [email protected]:/var/www/html/

    error එක


    Code:
    Run cd /home/runner/work/simple_app/simple_app/build/
      cd /home/runner/work/simple_app/simple_app/build/
      scp -i *** -r * [email protected]:/var/www/html/
      shell: /usr/bin/bash -e {0}
    Warning: Identity file ssh-rsa not accessible: No such file or directory.
    Host key verification failed.
    lost connection
    Error: Process completed with exit code 1.
     

    DevOps_Boy

    Active member
  • Jul 28, 2023
    238
    120
    43
    private key eka ohoma use karanne nathuwa.
    file ekakata echo karala
    echo ${{ secrets.SSH_PRIVATE_KEY }} > secret

    ita passe
    scp -i ./secret -r * [email protected]:/var/www/html/

    karala balapan
    run: |
    cd /home/runner/work/simple_app/simple_app/build/
    echo ${{ secrets.SSH_PRIVATE_KEY }} > secret
    scp -i ./secret -r * [email protected]:/var/www/html/

    මචන් මම මේක run කලාම එරර් එකක් එනවනෙ.
    error

    cd /home/runner/work/simple_app/simple_app/build/
    3 echo ***
    4 ***
    5 ***
    6 ***
    7 ***
    8 ***
    9 ***
    10 ***
    11 ***
    12 ***
    13 ***
    14 ***
    15 ***
    16 ***
    17 ***
    18 ***
    19 ***
    20 ***
    21 ***
    22 ***
    23 ***
    24 ***
    25 ***
    26 ***
    27 ***
    28 ***
    29 ***
    30 ***
    31 ***
    32 ***
    33 ***
    34 ***
    35 ***
    36 ***
    37 ***
    38 ***
    39 ***
    40 ***
    41 ***
    42 ***
    43 ***
    44 ***
    45 ***
    46 ***
    47 ***
    48 ***
    49 ***
    50 ***
    51 ***
    52 ***
    53 *** > secret
    54 scp -i ./secret -r * [email protected]:/var/www/html/
    55 shell: /usr/bin/bash -e {0}
    56***
    57/home/runner/work/_temp/c90078d0-b32f-476d-826c-cadca5f37b21.sh: line 3: ***: command not found
    58Error: Process completed with exit code 127.
     

    DevOps_Boy

    Active member
  • Jul 28, 2023
    238
    120
    43
    SSH private key eka file ekakata save karala use karanna.

    Naththam SCP deploy wage action ekak use karanna : https://github.com/marketplace/actions/scp-deploy-action
    මම මෙතනට private key එක දැම්මේ. උඩ කරපු විදිය නේද ඔයා කියන්නේ?

    1694883576589.png
     

    CustomerSupport

    Well-known member
  • Mar 21, 2016
    2,404
    1,515
    113
    මම මෙතනට private key එක දැම්මේ. උඩ කරපු විදිය නේද ඔයා කියන්නේ?

    View attachment 214721
    Oya widihata karama private key eka string variable ekak widihata thiyenne. SSH/SCP support karanne private key FILE ekak. E Nisa oya string eka file ekakata save karanna one CI eka athule.

    One nam PM ekak danna mama WhatsApp call ekakin kiyala dennam. Type karanna kammali
     
    • Like
    Reactions: Nadunf and LZP1992

    anonymouseninja

    Active member
  • Feb 20, 2022
    99
    135
    33
    London
    YAML:
    name: Deploy NodeJS application to DigitalOcean
    
    on:
      push:
        branches:
          - main
    
    jobs:
      deploy:
        runs-on: ubuntu-latest
    
        strategy:
          matrix:
            node-version: [16.x]
    
        steps:
          - name: Checkout repository
            uses: actions/checkout@v3
        
          - name: Use Node.js ${{ matrix.node-version }}
            uses: actions/setup-node@v3
            with:
              node-version: ${{ matrix.node-version }}
        
          - name: Install dependencies
            run: npm install
        
          - name: Build application
            run: npm run build --if-present
        
          - name: Deploy application to DigitalOcean
            uses: appleboy/ssh-action@master
            with:
              host: ${{ secrets.DIGITALOCEAN_HOST }}
              username: ${{ secrets.DIGITALOCEAN_USERNAME }}
              key: ${{ secrets.DIGITALOCEAN_PASSWORD }}
              script: |
                cd /var/www/repo
                pm2 stop index.js
                git pull https://${{ secrets.PAT_TOKEN }}@github.com/username/repo.git branch
                npm install
                pm2 start index.js
     

    helplesser

    Well-known member
  • Nov 20, 2017
    17,646
    27,156
    113
    36
    Mirihana
    alis.alberta.ca
    YAML:
    - name: Add SSH key to SSH agent
    
      run: |
    
        mkdir -p ~/.ssh
    
        echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
    
        chmod 600 ~/.ssh/id_rsa
    
        ssh-add ~/.ssh/id_rsa
    
    - name: Copy files to AWS server
    
      run: |
    
        cd /home/runner/work/simple_app/simple_app/build/
    
        scp -r * [email protected]:/var/www/html/