change: merge staging and production workflow
All checks were successful
Blog Deployment / check-hugo-version (push) Successful in 4s
Blog Deployment / build (push) Has been skipped
Blog Deployment / merge (push) Successful in 5s
Blog Deployment / deploy-staging (push) Successful in 9s
Blog Deployment / deploy-production (push) Successful in 9s
Blog Deployment / test-staging (push) Successful in 3s
Blog Deployment / test-production (push) Successful in 2s
Blog Deployment / clean (push) Has been skipped
All checks were successful
Blog Deployment / check-hugo-version (push) Successful in 4s
Blog Deployment / build (push) Has been skipped
Blog Deployment / merge (push) Successful in 5s
Blog Deployment / deploy-staging (push) Successful in 9s
Blog Deployment / deploy-production (push) Successful in 9s
Blog Deployment / test-staging (push) Successful in 3s
Blog Deployment / test-production (push) Successful in 2s
Blog Deployment / clean (push) Has been skipped
This commit is contained in:
parent
853beb33a4
commit
fe32c88403
@ -1,13 +1,13 @@
|
|||||||
name: Staging Blog Deployment
|
name: Blog Deployment
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- preview
|
- preview
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKER_IMAGE: vezpi-blog
|
DOCKER_IMAGE: vezpi-blog
|
||||||
CONTAINER_NAME: blog_staging
|
|
||||||
URL: "https://blog-dev.vezpi.com/en/"
|
|
||||||
jobs:
|
jobs:
|
||||||
check-hugo-version:
|
check-hugo-version:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
@ -19,20 +19,20 @@ jobs:
|
|||||||
current_hugo_version: ${{ steps.get_current.outputs.version }}
|
current_hugo_version: ${{ steps.get_current.outputs.version }}
|
||||||
newer_version_available: ${{ steps.compare.outputs.version }}
|
newer_version_available: ${{ steps.compare.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check latest Hugo version
|
- name: Check Latest Hugo Version
|
||||||
id: get_latest
|
id: get_latest
|
||||||
run: |
|
run: |
|
||||||
apk add curl
|
apk add curl
|
||||||
latest_version=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep tag_name | sed -E 's/.*"v([^"]+)".*/\1/')
|
latest_version=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep tag_name | sed -E 's/.*"v([^"]+)".*/\1/')
|
||||||
echo "version=$latest_version" | tee -a $GITEA_OUTPUT
|
echo "version=$latest_version" | tee -a $GITEA_OUTPUT
|
||||||
|
|
||||||
- name: Check current Hugo version
|
- name: Check Current Hugo Version
|
||||||
id: get_current
|
id: get_current
|
||||||
run: |
|
run: |
|
||||||
current_version=$(docker image ls ${DOCKER_IMAGE} --format '{{.Tag}}' | head -n1)
|
current_version=$(docker image ls ${DOCKER_IMAGE} --format '{{.Tag}}' | head -n1)
|
||||||
echo "version=$current_version" | tee -a $GITEA_OUTPUT
|
echo "version=$current_version" | tee -a $GITEA_OUTPUT
|
||||||
|
|
||||||
- name: Compare current and latest Hugo versions
|
- name: Compare Current and Latest Hugo Versions
|
||||||
id: compare
|
id: compare
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ steps.get_latest.outputs.version }}" != "${{ steps.get_current.outputs.version }}" ]; then
|
if [ "${{ steps.get_latest.outputs.version }}" != "${{ steps.get_current.outputs.version }}" ]; then
|
||||||
@ -52,7 +52,7 @@ jobs:
|
|||||||
run:
|
run:
|
||||||
shell: sh
|
shell: sh
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout Repository
|
||||||
run: git clone --branch preview https://${{ secrets.REPO_TOKEN }}@git.vezpi.me/Vezpi/blog.git .
|
run: git clone --branch preview https://${{ secrets.REPO_TOKEN }}@git.vezpi.me/Vezpi/blog.git .
|
||||||
|
|
||||||
- name: Build Docker Image
|
- name: Build Docker Image
|
||||||
@ -64,7 +64,7 @@ jobs:
|
|||||||
.
|
.
|
||||||
docker tag ${DOCKER_IMAGE}:${{ needs.check-hugo-version.outputs.latest_hugo_version }} ${DOCKER_IMAGE}:latest
|
docker tag ${DOCKER_IMAGE}:${{ needs.check-hugo-version.outputs.latest_hugo_version }} ${DOCKER_IMAGE}:latest
|
||||||
|
|
||||||
deploy:
|
deploy-staging:
|
||||||
needs:
|
needs:
|
||||||
- check-hugo-version
|
- check-hugo-version
|
||||||
- build
|
- build
|
||||||
@ -76,8 +76,10 @@ jobs:
|
|||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: sh
|
shell: sh
|
||||||
|
env:
|
||||||
|
CONTAINER_NAME: blog_staging
|
||||||
steps:
|
steps:
|
||||||
- name: Restart ${CONTAINER_NAME} container
|
- name: Launch Blog Deployment
|
||||||
run: |
|
run: |
|
||||||
cd /blog
|
cd /blog
|
||||||
docker compose down ${CONTAINER_NAME}
|
docker compose down ${CONTAINER_NAME}
|
||||||
@ -86,11 +88,13 @@ jobs:
|
|||||||
echo "- Displaying container logs"
|
echo "- Displaying container logs"
|
||||||
docker compose logs ${CONTAINER_NAME}
|
docker compose logs ${CONTAINER_NAME}
|
||||||
|
|
||||||
test:
|
test-staging:
|
||||||
needs: deploy
|
needs: deploy-staging
|
||||||
runs-on: ubuntu
|
runs-on: ubuntu
|
||||||
|
env:
|
||||||
|
URL: "https://blog-dev.vezpi.com/en/"
|
||||||
steps:
|
steps:
|
||||||
- name: Check HTTP response
|
- name: Check HTTP Response
|
||||||
run: |
|
run: |
|
||||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
|
code=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
|
||||||
echo "HTTP response code: $code"
|
echo "HTTP response code: $code"
|
||||||
@ -106,26 +110,65 @@ jobs:
|
|||||||
needs: test
|
needs: test
|
||||||
runs-on: ubuntu
|
runs-on: ubuntu
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: main
|
ref: main
|
||||||
|
|
||||||
- name: Merge preview branch on main
|
- name: Merge preview Branch on main
|
||||||
run: |
|
run: |
|
||||||
git merge --ff-only origin/preview
|
git merge --ff-only origin/preview
|
||||||
git push origin main
|
git push origin main
|
||||||
|
|
||||||
|
deploy-production:
|
||||||
|
needs: merge
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
volumes:
|
||||||
|
- /appli/docker/blog:/blog
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
CONTAINER_NAME: blog_production
|
||||||
|
steps:
|
||||||
|
- name: Launch Blog Deployment
|
||||||
|
run: |
|
||||||
|
cd /blog
|
||||||
|
docker compose down ${CONTAINER_NAME}
|
||||||
|
docker compose up -d ${CONTAINER_NAME}
|
||||||
|
sleep 5
|
||||||
|
echo "- Displaying container logs"
|
||||||
|
docker compose logs ${CONTAINER_NAME}
|
||||||
|
|
||||||
|
test-production:
|
||||||
|
needs: deploy-production
|
||||||
|
runs-on: ubuntu
|
||||||
|
env:
|
||||||
|
URL: "https://blog.vezpi.com/en/"
|
||||||
|
steps:
|
||||||
|
- name: Check HTTP Response
|
||||||
|
run: |
|
||||||
|
code=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
|
||||||
|
echo "HTTP response code: $code"
|
||||||
|
|
||||||
|
if [ "$code" -ne 200 ]; then
|
||||||
|
echo "❌ Service is not healthy (HTTP $code)"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "✅ Service is healthy"
|
||||||
|
fi
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
needs:
|
needs:
|
||||||
- check-hugo-version
|
- check-hugo-version
|
||||||
- build
|
- build
|
||||||
- merge
|
- test-production
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: sh
|
shell: sh
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout Repository
|
||||||
run: docker image rm vezpi-blog:${{ needs.check-hugo-version.outputs.current_hugo_version }} --force
|
run: docker image rm vezpi-blog:${{ needs.check-hugo-version.outputs.current_hugo_version }} --force
|
@ -1,48 +0,0 @@
|
|||||||
name: Production Blog Deployment
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_run:
|
|
||||||
workflows: ["Staging Blog Deployment"]
|
|
||||||
types: [completed]
|
|
||||||
branches:
|
|
||||||
- 'preview'
|
|
||||||
|
|
||||||
env:
|
|
||||||
CONTAINER_NAME: blog_production
|
|
||||||
URL: "https://blog.vezpi.com/en/"
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
volumes:
|
|
||||||
- /appli/docker/blog:/blog
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: sh
|
|
||||||
steps:
|
|
||||||
- name: Restart ${CONTAINER_NAME} container
|
|
||||||
run: |
|
|
||||||
cd /blog
|
|
||||||
docker compose down ${CONTAINER_NAME}
|
|
||||||
docker compose up -d ${CONTAINER_NAME}
|
|
||||||
sleep 5
|
|
||||||
echo "- Displaying container logs"
|
|
||||||
docker compose logs ${CONTAINER_NAME}
|
|
||||||
|
|
||||||
test:
|
|
||||||
needs: deploy
|
|
||||||
runs-on: ubuntu
|
|
||||||
steps:
|
|
||||||
- name: Check HTTP response
|
|
||||||
run: |
|
|
||||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
|
|
||||||
echo "HTTP response code: $code"
|
|
||||||
|
|
||||||
if [ "$code" -ne 200 ]; then
|
|
||||||
echo "❌ Service is not healthy (HTTP $code)"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "✅ Service is healthy"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user