CI/CD Workflow para github actions y docker. Logear la cuenta de dockerhub en el server.
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
# This is a basic workflow to help you get started with Actions | |
name: CI/CD | |
# Controls when the action will run. | |
on: | |
push: | |
branches: [main] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/engineering:xml-transactions-api | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
- name: CD | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: | | |
cd /home/centos/api-xml | |
docker-compose down | |
docker pull medirec/engineering:xml-transactions-api | |
docker-compose up -d | |
host: ${{ secrets.HOST }} | |
username: centos | |
passphrase: ${{ secrets.PASSPHRASE }} | |
privateKey: ${{ secrets.PRIVATE_KEY}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tomasmetal23 commentedJun 8, 2021