CD-CLIENTES-QA #21
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: CD-CLIENTES-QA | |
on: | |
workflow_dispatch: | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.PEM_CLIENTES_QA }} | |
REMOTE_USER: ec2-user | |
REMOTE_HOST: ${{ secrets.IP_CLIENTES_QA }} | |
APP_NAME: app.js | |
DOCKERHUB_TOKEN: ${{ secrets.DH_TOKEN_CLIENTES }} | |
DOCKERHUB_USERNAME: romicalani | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Iniciar sesion en Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ env.DOCKERHUB_TOKEN }} | |
- name: Generar imagen Docker | |
run: | | |
docker build . -t ${{env.DOCKERHUB_USERNAME }}/node-app:latest | |
- name: Subir imagen Docker | |
run: | | |
docker push ${{env.DOCKERHUB_USERNAME }}/node-app:latest | |
- name: Instalar docker | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ env.REMOTE_HOST }} | |
username: ${{ env.REMOTE_USER }} | |
key: ${{ env.SSH_PRIVATE_KEY }} | |
script: | | |
if ! command -v docker > /dev/null; then | |
sudo yum install docker | |
else | |
echo "docker is installed." | |
fi | |
- name: Descargar imagen docker | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ env.REMOTE_HOST }} | |
username: ${{ env.REMOTE_USER }} | |
key: ${{ env.SSH_PRIVATE_KEY }} | |
script: | | |
docker pull ${{env.DOCKERHUB_USERNAME }}/node-app:latest | |
docker run -dp 3000:3000 ${{env.DOCKERHUB_USERNAME }}/node-app:latest |