CI: build once with sha-* tags, promote to stage without rebuild.
This commit is contained in:
@@ -5,12 +5,19 @@ on:
|
|||||||
branches: [master, main]
|
branches: [master, main]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: git.sabilin.com/eventhub
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy-ift-core:
|
deploy-ift-core:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Compute image tag
|
||||||
|
id: meta
|
||||||
|
run: echo "tag=sha-${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
@@ -27,7 +34,9 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: docker/Dockerfile
|
file: docker/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: git.sabilin.com/eventhub/eventhub:ift
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/eventhub:${{ steps.meta.outputs.tag }}
|
||||||
|
${{ env.REGISTRY }}/eventhub:ift
|
||||||
|
|
||||||
- name: Build and push traefik-coraza
|
- name: Build and push traefik-coraza
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
@@ -35,7 +44,9 @@ jobs:
|
|||||||
context: docker/traefik
|
context: docker/traefik
|
||||||
file: docker/traefik/Dockerfile
|
file: docker/traefik/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: git.sabilin.com/eventhub/traefik-coraza:ift
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/traefik-coraza:${{ steps.meta.outputs.tag }}
|
||||||
|
${{ env.REGISTRY }}/traefik-coraza:ift
|
||||||
|
|
||||||
- name: Build and push fallback
|
- name: Build and push fallback
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
@@ -43,7 +54,9 @@ jobs:
|
|||||||
context: docker/fallback
|
context: docker/fallback
|
||||||
file: docker/fallback/Dockerfile
|
file: docker/fallback/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: git.sabilin.com/eventhub/fallback:ift
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/fallback:${{ steps.meta.outputs.tag }}
|
||||||
|
${{ env.REGISTRY }}/fallback:ift
|
||||||
|
|
||||||
- name: Build and push bot-emulator
|
- name: Build and push bot-emulator
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
@@ -51,7 +64,9 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: test/emulate_users/Dockerfile
|
file: test/emulate_users/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: git.sabilin.com/eventhub/bot-emulator-users:ift
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/bot-emulator-users:${{ steps.meta.outputs.tag }}
|
||||||
|
${{ env.REGISTRY }}/bot-emulator-users:ift
|
||||||
|
|
||||||
- name: Deploy core on IFT via SSH
|
- name: Deploy core on IFT via SSH
|
||||||
uses: appleboy/ssh-action@v0.1.5
|
uses: appleboy/ssh-action@v0.1.5
|
||||||
@@ -62,4 +77,4 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
export REGISTRY_USER='${{ secrets.REGISTRY_USER }}'
|
export REGISTRY_USER='${{ secrets.REGISTRY_USER }}'
|
||||||
export REGISTRY_PASSWORD='${{ secrets.REGISTRY_PASSWORD }}'
|
export REGISTRY_PASSWORD='${{ secrets.REGISTRY_PASSWORD }}'
|
||||||
/opt/eventhub-ift/devops/scripts/deploy-service.sh ift core
|
/opt/eventhub-ift/devops/scripts/deploy-service.sh ift core ${{ steps.meta.outputs.tag }}
|
||||||
|
|||||||
@@ -6,12 +6,21 @@ on:
|
|||||||
- 'v*'
|
- 'v*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: git.sabilin.com/eventhub
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy-stage-core:
|
deploy-stage-core:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Compute image tags
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
echo "sha_tag=sha-${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "release_tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
@@ -22,20 +31,29 @@ jobs:
|
|||||||
username: ${{ secrets.REGISTRY_USER }}
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and push eventhub
|
- name: Promote images (no rebuild)
|
||||||
uses: docker/build-push-action@v4
|
run: |
|
||||||
with:
|
set -euo pipefail
|
||||||
context: .
|
SHA="${{ steps.meta.outputs.sha_tag }}"
|
||||||
push: true
|
REL="${{ steps.meta.outputs.release_tag }}"
|
||||||
tags: git.sabilin.com/eventhub/eventhub:stage
|
IMAGES="eventhub traefik-coraza fallback bot-emulator-users"
|
||||||
|
missing=""
|
||||||
- name: Build and push bot-emulator
|
for img in ${IMAGES}; do
|
||||||
uses: docker/build-push-action@v4
|
if ! docker buildx imagetools inspect "${REGISTRY}/${img}:${SHA}" >/dev/null 2>&1; then
|
||||||
with:
|
missing="${missing} ${img}"
|
||||||
context: .
|
fi
|
||||||
file: test/emulate_users/Dockerfile
|
done
|
||||||
push: true
|
if [[ -n "${missing}" ]]; then
|
||||||
tags: git.sabilin.com/eventhub/bot-emulator-users:stage
|
echo "Образы sha:${SHA} не найдены:${missing}"
|
||||||
|
echo "Сначала прогоните IFT deploy для этого коммита (push в master)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
for img in ${IMAGES}; do
|
||||||
|
docker buildx imagetools create \
|
||||||
|
-t "${REGISTRY}/${img}:${REL}" \
|
||||||
|
-t "${REGISTRY}/${img}:stage" \
|
||||||
|
"${REGISTRY}/${img}:${SHA}"
|
||||||
|
done
|
||||||
|
|
||||||
- name: Deploy core on stage via SSH
|
- name: Deploy core on stage via SSH
|
||||||
uses: appleboy/ssh-action@v0.1.5
|
uses: appleboy/ssh-action@v0.1.5
|
||||||
@@ -46,4 +64,4 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
export REGISTRY_USER='${{ secrets.REGISTRY_USER }}'
|
export REGISTRY_USER='${{ secrets.REGISTRY_USER }}'
|
||||||
export REGISTRY_PASSWORD='${{ secrets.REGISTRY_PASSWORD }}'
|
export REGISTRY_PASSWORD='${{ secrets.REGISTRY_PASSWORD }}'
|
||||||
/opt/eventhub-stage/devops/scripts/deploy-service.sh stage core
|
/opt/eventhub-stage/devops/scripts/deploy-service.sh stage core ${{ steps.meta.outputs.release_tag }}
|
||||||
|
|||||||
Reference in New Issue
Block a user