Skip to content

Add nginx

Add nginx #27

name: build-deploy-docker
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
GITLAB_REGISTRY_USERNAME: ${{ secrets.GITLAB_REGISTRY_USERNAME }}
GITLAB_REGISTRY_TOKEN: ${{ secrets.GITLAB_REGISTRY_TOKEN }}
jobs:
detect-changes:
runs-on: ubuntu-20.04
permissions:
pull-requests: read
outputs:
gateway: ${{ steps.paths_filter.outputs.gateway }}
nginx: ${{ steps.paths_filter.outputs.nginx }}
steps:
- name: Execute paths filter.
uses: dorny/paths-filter@v3
id: paths_filter
with:
filters: |
gateway:
- "./gateway/**"
nginx:
- "./nginx/**"
build-gateway:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.gateway == 'true' }}
runs-on: ubuntu-20.04
steps:
- name: Check out repo.
uses: actions/checkout@v4
- name: Setup buildx
run: docker buildx create --use
- name: Sign in to segmentation gitlab registry.
run: echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
- name: Build gateway image.
run: |
docker buildx build \
--platform linux/arm64 \
--tag registry.gitlab.com/segmentation964330/service/gateway \
--push \
./gateway
build-nginx:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.nginx == 'true' }}
runs-on: ubuntu-20.04
steps:
- name: Check out repo.
uses: actions/checkout@v4
- name: Setup buildx
run: docker buildx create --use
- name: Sign in to segmentation gitlab registry.
run: echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
- name: Build nginx image.
run: |
docker buildx build \
--platform linux/arm64 \
--tag registry.gitlab.com/segmentation964330/service/nginx \
--push \
./nginx
deploy:
runs-on: ubuntu-20.04
needs: [build-gateway, build-nginx]
if: ${{ always() && !failure() && !cancelled() }}
steps:
- name: Check out repo.
uses: actions/checkout@v4
- name: Copy docker compose file to OCI.
uses: appleboy/[email protected]
with:
host: ${{ secrets.ORACLE_HOST }}
username: ${{ secrets.ORACLE_USERNAME }}
key: ${{ secrets.ORACLE_SSH_KEY }}
source: "./docker-compose.yml"
target: "."
- name: Pull docker and deploy.
uses: appleboy/[email protected]
with:
host: ${{ secrets.ORACLE_HOST }}
username: ${{ secrets.ORACLE_USERNAME }}
key: ${{ secrets.ORACLE_SSH_KEY }}
envs: GITLAB_REGISTRY_USERNAME, GITLAB_REGISTRY_TOKEN
script: |
echo "$GITLAB_REGISTRY_TOKEN" | docker login registry.gitlab.com -u "$GITLAB_REGISTRY_USERNAME" --password-stdin
sudo docker compose down
sudo docker compose pull
sudo docker compose up --detach
sudo docker image prune --force