-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Abhinav Gautam
authored and
Abhinav Gautam
committed
Oct 14, 2024
1 parent
ee51dc0
commit ba6d122
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
DOCKER_REPO: puppet-master | ||
DOCKER_IMAGE: prod | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ vars.DOCKER_BUILD_RUNNER }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to Harbor | ||
run: echo "${{ secrets.HARBOR_PASSWORD }}" | docker login https://harbor.internal.codebuckets.in -u '${{ secrets.HARBOR_USER }}' --password-stdin | ||
|
||
- name: Build Docker image | ||
run: docker build -t harbor.internal.codebuckets.in/${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:latest . -f Dockerfile | ||
|
||
- name: Push Docker image | ||
run: docker push harbor.internal.codebuckets.in/${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:latest | ||
|
||
deploy: | ||
runs-on: prod-server-hetzner | ||
needs: build | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Pull new Image | ||
run: docker compose -f docker-compose.yml pull | ||
|
||
- name: Remove old containers | ||
run: docker compose -f docker-compose.yml down || true | ||
|
||
- name: Start Container | ||
run: docker compose -f docker-compose.yml up -d |