name: Push-to-EC2 Trigger deployment only on push to main branch on: push: branches:…
Private research annotation
Sign in to add a private research label or note.
- User
name: Push-to-EC2
Trigger deployment only on push to main branch
on: push: branches: ["main"]
jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [14.x]
codesteps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: "npm" - run: npm install env: CI: false - run: CI=false npm run build env: CI: false # Share artifact inside workflow - uses: actions/upload-artifact@v3 with: name: react-github-actions-build path: build retention-days: 1 - uses: actions/upload-artifact@v3 with: name: react-github-actions-build path: pm2.json retention-days: 1deploy: name: Deploy to EC2 on main branch push runs-on: ubuntu-latest needs: build steps: # Download previously shared build - name: Get artifact uses: actions/download-artifact@v3 with: name: react-github-actions-build - name: Display structure of downloaded files run: ls -R
code- name: Deploy to Server uses: easingthemes/ssh-deploy@main the above is the github actions yaml for my react project and everytime main is updated the wroker fails and tries to create a new instance. What is the issue and how do i fix it ? - Assistant
It's hard to say exactly what the issue is without more information, but it sounds like the worker is attempting to create a new EC2 instance on every deployment, which could be due to a misconfiguration in your SSH deploy action or your AWS settings.
Here are some potential steps you could take to troubleshoot and resolve the issue:
-
Check your SSH deploy action configuration: Take a closer look at the SSH deploy step in your workflow and ensure that you've configured it correctly for your EC2 instance. This could include checking the correct IP address, user credentials, and SSH keys.
-
Verify your AWS settings: Make sure your AWS settings are properly configured, specifically checking if you've set up auto-scaling or any other settings that could be causing multiple instances to be created.
-
Debug the workflow: Try adding additional debugging steps to your workflow to help pinpoint where the issue is occurring. For example, you could add a step to display any relevant error messages, or to log the output of each step in the process.
-
- User
name: Push-to-EC2
Trigger deployment only on push to main branch
on: push: branches: ["main"]
jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [14.x]
code - Assistant
Based on the YAML you provided, it doesn't seem like you're creating a new EC2 instance on every deployment. The problem could be related to how the
easingthemes/ssh-deployaction is working or to your AWS settings.Here are some potential debugging steps you could take:
-
Check the logs: Check the logs generated by the
deployjob in your workflow to see if there are any relevant error messages. You can access job logs by going to the "Actions" tab in your repository and clicking on the specific workflow run you want to inspect. -
Verify your SSH deploy action configuration: Double-check that the
SSH_PRIVATE_KEY,REMOTE_HOST, , and environment variables are all set correctly. You could also try running the step locally to ensure that it works as expected.
-