feat(infra): created gateway vpc endpoint for communication between E… #380
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 - Stage | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-client-api: | |
name: Build client-api image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v6 | |
with: | |
file: ./apps/backend/Dockerfile # build with root context | |
push: true | |
build-args: | | |
target=client | |
app_env=stage | |
tags: ghcr.io/${{ github.repository_owner }}/codedang-client-api:latest | |
build-admin-api: | |
name: Build admin-api image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v6 | |
with: | |
file: ./apps/backend/Dockerfile # build with root context | |
push: true | |
build-args: | | |
target=admin | |
app_env=stage | |
tags: ghcr.io/${{ github.repository_owner }}/codedang-admin-api:latest | |
build-iris: | |
name: Build Iris docker image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push iris image | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
context: '{{defaultContext}}:apps/iris' | |
build-args: | | |
app_env=stage | |
tags: ghcr.io/${{ github.repository_owner }}/codedang-iris:latest | |
run-server: | |
name: Run stage server | |
runs-on: self-hosted | |
needs: [build-client-api, build-admin-api, build-iris] | |
environment: stage | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
docker-compose.yml | |
scripts/deploy.sh | |
.env.development | |
apps/infra/stage/Caddyfile | |
apps/grafana-logs/promtail/promtail-config.yml | |
- name: Load dotenv from secret | |
run: | | |
echo "${{ secrets.ENV_DEVELOPMENT }}" > .env | |
echo "${{ secrets.LOKI_SERVER_URL }}" >> .env | |
- name: Check if containers are running | |
id: check-container | |
run: | | |
{ | |
echo 'stdout<<EOF' | |
docker compose --profile deploy ps -q | |
echo EOF | |
} >> "$GITHUB_OUTPUT" | |
- name: Initialize containers | |
if: steps.check-container.outputs.stdout == '' | |
run: docker compose --profile deploy up -d --no-recreate | |
- name: Pull docker images | |
run: docker compose --profile update-target pull | |
- name: Run docker compose up | |
run: | | |
docker compose --profile deploy up backend-client -d --no-deps | |
docker compose --profile deploy up backend-admin -d --no-deps | |
docker compose --profile deploy up iris -d --no-deps | |
docker compose --profile deploy up promtail -d --no-deps | |
- name: Copy Caddyfile into Caddy Container | |
run: docker cp ./apps/infra/stage/Caddyfile caddy:/etc/caddy/Caddyfile | |
- name: Graceful reload Caddy | |
run: docker exec -w /etc/caddy caddy caddy reload | |
- name: Remove unused docker storages | |
run: docker system prune -a -f --volumes | |
# TODO: Uncomment this section when E2E test is ready | |
# e2e-test: | |
# name: Run E2E test | |
# runs-on: ubuntu-latest | |
# needs: [run-server] | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: actions/setup-node@v4 | |
# with: | |
# node-version: 20 | |
# - name: Install Bruno CLI | |
# run: npm install -g @usebruno/cli | |
# - name: Run Bruno Collection (Client) | |
# working-directory: ./collection/client | |
# run: bru run --env Stage | |
# - name: Run Bruno Collection (Admin) | |
# working-directory: ./collection/admin | |
# run: bru run --env Stage |