Skip to content

Fix UI_CONTAITER_NAME #16

Fix UI_CONTAITER_NAME

Fix UI_CONTAITER_NAME #16

Workflow file for this run

name: Deploy docker
on:
push:
branches: ['main']
tags:
- 'v*'
env:
REGISTRY: ghcr.io
API_IMAGE_NAME: dyakovri/redirector-api
UI_IMAGE_NAME: dyakovri/redirector-ui
API_CONTAITER_NAME: com_profcomff_api_redirect
UI_CONTAITER_NAME: com_profcomff_ui_redirect
jobs:
build-testing:
name: Build testing
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: ${{ env.UI_IMAGE_NAME }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/profcomff/redirect-ui
tags: |
type=raw,value=test,enable=true
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
API_ROOT=https://to.test.profcomff.com
deploy-testing:
name: Deploy Testing
runs-on: [self-hosted, Linux]
needs: build-testing
environment:
name: Testing
url: https://to.test.profcomff.com/
permissions:
packages: read
steps:
- name: Pull new API
run: docker pull ${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}:master
- name: Pull new UI
run: docker pull ${{ env.REGISTRY }}/profcomff/redirect-ui:test
- name: Migrate DB
run: |
docker run \
--rm \
--network=web \
--env DB_DSN=${{ secrets.DB_DSN }} \
--name ${{ env.API_CONTAITER_NAME }}_migration \
${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}:master \
alembic upgrade head
- name: Run test API
run: |
docker stop ${{ env.API_CONTAITER_NAME }}_test || true && docker rm ${{ env.API_CONTAITER_NAME }}_test || true
docker run \
--detach \
--restart on-failure:3 \
--network=web \
--env DB_DSN=${{ secrets.DB_DSN }} \
--name ${{ env.API_CONTAITER_NAME }}_test \
${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}:master
- name: Run test UI
run: |
docker stop ${{ env.UI_CONTAITER_NAME }}_test || true && docker rm ${{ env.UI_CONTAITER_NAME }}_test || true
docker run \
--detach \
--restart on-failure:3 \
--network=web \
--name ${{ env.UI_CONTAITER_NAME }}_test \
${{ env.REGISTRY }}/profcomff/redirect-ui:test
build-production:
name: Build production
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: ${{ env.UI_IMAGE_NAME }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/profcomff/redirect-ui
tags: |
type=ref,event=tag,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
API_ROOT=https://to.profcomff.com
deploy-production:
name: Deploy Production
needs:
- build-production
- deploy-testing
if: startsWith(github.ref, 'refs/tags/v')
runs-on: [self-hosted, Linux]
environment:
name: Production
url: https://to.profcomff.com/
permissions:
packages: read
steps:
- name: Pull new API
run: docker pull ${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}:master
- name: Pull new UI
run: docker pull ${{ env.REGISTRY }}/profcomff/redirect-ui:latest
- name: Migrate DB
run: |
docker run \
--rm \
--network=web \
--env DB_DSN=${{ secrets.DB_DSN }} \
--name ${{ env.API_CONTAITER_NAME }}_migration \
${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}:master \
alembic upgrade head
- name: Run test API
run: |
docker stop ${{ env.API_CONTAITER_NAME }} || true && docker rm ${{ env.API_CONTAITER_NAME }} || true
docker run \
--detach \
--restart always \
--network=web \
--env DB_DSN=${{ secrets.DB_DSN }} \
--env SECRET=${{ secrets.SECRET }} \
--name ${{ env.API_CONTAITER_NAME }} \
${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}:master
- name: Run test UI
run: |
docker stop ${{ env.UI_CONTAITER_NAME }} || true && docker rm ${{ env.UI_CONTAITER_NAME }} || true
docker run \
--detach \
--restart always \
--network=web \
--name ${{ env.UI_CONTAITER_NAME }} \
${{ env.REGISTRY }}/profcomff/redirect-ui:latest