Skip to content

Commit

Permalink
✨ apply runner a b to actions script
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed Oct 23, 2024
1 parent 420fe0d commit 5ecadf9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 35 deletions.
45 changes: 19 additions & 26 deletions .github/workflows/be-cd-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,49 +68,42 @@ jobs:
- name: Push Docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:prod

- name: Upload docker compose
uses: actions/upload-artifact@v4
with:
name: docker-compose
path: ./backend/src/main/resources/docker-compose-prod.yaml
if-no-files-found: error

deploy:
deploy-a:
needs: build
runs-on: [self-hosted, prod]
runs-on: [self-hosted, prod-a]
environment: prod

steps:
- name: Set up environment variables
run: |
cd ~/${{ secrets.DOCKERHUB_IMAGE_NAME }}
echo "JASYPT_PASSWORD=${{ secrets.JASYPT_PASSWORD }}" >> .env
- name: Download docker compose
uses: actions/download-artifact@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
name: docker-compose
path: ~/${{ secrets.DOCKERHUB_IMAGE_NAME }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Rename downloaded file
- name: Run toggle script
run: |
cd ~/${{ secrets.DOCKERHUB_IMAGE_NAME }}
mv docker-compose-prod.yaml docker-compose.yaml
./run-toggle.sh
- name: Clean up unused Docker images
run: docker image prune -af

deploy-b:
needs: build
runs-on: [self-hosted, prod-b]
environment: prod

steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Pull latest Docker images
run: docker compose -f ~/${{ secrets.DOCKERHUB_IMAGE_NAME }}/docker-compose.yaml pull

- name: Restart docker compose
- name: Run toggle script
run: |
cd ~/${{ secrets.DOCKERHUB_IMAGE_NAME }}
docker compose down
docker compose up -d
./run-toggle.sh
- name: Clean up unused Docker images
run: docker image prune -af
9 changes: 0 additions & 9 deletions backend/src/main/resources/docker-compose-prod.yaml

This file was deleted.

0 comments on commit 5ecadf9

Please sign in to comment.