From 3ca17a930ed92fe71147ddd8023d24ccc73a982e Mon Sep 17 00:00:00 2001 From: Jayden Pyles Date: Wed, 26 Jun 2024 16:06:01 -0500 Subject: [PATCH] wip: add ci --- .github/workflows/docker-image.yml | 26 ++++++++++++++++++++++++++ Makefile | 7 +++++++ ansible/config.yaml | 1 + ansible/deploy_site.yaml | 4 ++-- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..ab650a4 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,26 @@ +name: ci +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{secrets.DOCKERHUB_REPO}}:latest diff --git a/Makefile b/Makefile index 2045b6d..2b8670a 100644 --- a/Makefile +++ b/Makefile @@ -43,3 +43,10 @@ up-dev: down: $(COMPOSE_DEV) down $(COMPOSE_PROD) down + +setup: + ansible-playbook -i ./ansible/inventory.yaml ./ansible/setup.yaml + +deploy: + ansible-playbook -i ./ansible/inventory.yaml ./ansible/deploy_site.yaml + diff --git a/ansible/config.yaml b/ansible/config.yaml index 8b2c49d..1db920a 100644 --- a/ansible/config.yaml +++ b/ansible/config.yaml @@ -1,2 +1,3 @@ github_repo: https://github.com/jaypyles/webapp-template.git deploy_path: /home/admin/website +deploy_command: make pull up-prd diff --git a/ansible/deploy_site.yaml b/ansible/deploy_site.yaml index 9a8e79b..c76d374 100644 --- a/ansible/deploy_site.yaml +++ b/ansible/deploy_site.yaml @@ -4,7 +4,7 @@ vars_files: - ./config.yaml tasks: - - name: Run make pull up - command: make pull up + - name: Deploy + command: "{{deploy_command}}" args: chdir: "{{deploy_path}}"