chnage app run to make it outside the systemd #2
This file contains hidden or 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 Node.js App with Ansible | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: dev | |
| env: | |
| IMAGE_NAME: docker.io/therealpad/my-node-app | |
| CONTAINER_NAME: my-node-app | |
| PORT: 3000 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build Docker image | |
| run: | | |
| docker build -t $IMAGE_NAME:latest ./server | |
| - name: Push Docker image | |
| run: | | |
| docker push $IMAGE_NAME:latest | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.x" | |
| - name: Install Ansible | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ansible | |
| - name: Set up SSH | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| - name: Add target host to known_hosts | |
| run: | | |
| HOST_IP=$(grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' inventory.ini | head -n 1) | |
| ssh-keyscan $HOST_IP >> ~/.ssh/known_hosts | |
| - name: Run Ansible Playbook | |
| run: | | |
| ansible-playbook -i inventory.ini setup.yml \ | |
| --extra-vars "node_username=${{ secrets.NODE_USERNAME }} \ | |
| node_password=${{ secrets.NODE_PASSWORD }} \ | |
| secret_message='${{ secrets.SECRET_MESSAGE }}'" | |
| env: | |
| ANSIBLE_HOST_KEY_CHECKING: "False" |