trigger redeploy #15
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: Plone Conference testing CI | |
on: | |
push: | |
paths: | |
- "backend/**" | |
- "frontend/**" | |
- ".github/workflows/backend.yml" | |
- ".github/workflows/frontend.yml" | |
- ".github/workflows/main.yml" | |
- "devops/**" | |
workflow_dispatch: | |
env: | |
IMAGE_NAME_PREFIX: ghcr.io/plone/2025.ploneconf.org | |
NODE_VERSION: "22.x" | |
PYTHON_VERSION: "3.12" | |
STACK_PARAM: latest | |
STACK_NAME: testing-ploneconf-org | |
STACK_PREFIX: testing_ploneconf | |
PUBLIC_URL: testing.ploneconf.org | |
CERTRESOLVER: le-cloudflare | |
STACK_FILE: devops/stacks/testing.ploneconf.org.yml | |
jobs: | |
config: | |
runs-on: ubuntu-latest | |
outputs: | |
backend: ${{ steps.filter.outputs.backend }} | |
frontend: ${{ steps.filter.outputs.frontend }} | |
BASE_TAG: ${{ steps.vars.outputs.BASE_TAG }} | |
IMAGE_NAME_PREFIX: ${{ env.IMAGE_NAME_PREFIX }} | |
NODE_VERSION: ${{ env.NODE_VERSION }} | |
PYTHON_VERSION: ${{ env.PYTHON_VERSION }} | |
PLONE_VERSION: ${{ steps.vars.outputs.PLONE_VERSION }} | |
VOLTO_VERSION: ${{ steps.vars.outputs.VOLTO_VERSION }} | |
DEPLOY_ENVIRONMENT: ${{ steps.vars.outputs.DEPLOY_ENVIRONMENT }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Compute several vars needed for the CI | |
id: vars | |
run: | | |
echo "BASE_TAG=sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
echo "PLONE_VERSION=$(cat backend/version.txt)" >> $GITHUB_OUTPUT | |
python3 -c 'import json; data = json.load(open("./frontend/mrs.developer.json")); print("VOLTO_VERSION=" + (data["core"].get("tag") or "latest"))' >> $GITHUB_OUTPUT | |
echo "DEPLOY_ENVIRONMENT=${{ env.PUBLIC_URL }}" >> $GITHUB_OUTPUT | |
- name: Test vars | |
run: | | |
echo 'BASE_TAG=${{ steps.vars.outputs.BASE_TAG }}' | |
echo 'PLONE_VERSION=${{ steps.vars.outputs.PLONE_VERSION }}' | |
echo 'VOLTO_VERSION=${{ steps.vars.outputs.VOLTO_VERSION }}' | |
echo "DEPLOY_ENVIRONMENT=${{ env.PUBLIC_URL }}" >> $GITHUB_OUTPUT | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
backend: | |
- 'backend/**' | |
- '.github/workflows/backend.yml' | |
frontend: | |
- 'frontend/**' | |
- '.github/workflows/frontend.yml' | |
backend: | |
uses: ./.github/workflows/backend.yml | |
needs: | |
- config | |
with: | |
base-tag: ${{ needs.config.outputs.BASE_TAG }} | |
image-name-prefix: ${{ needs.config.outputs.IMAGE_NAME_PREFIX }} | |
image-name-suffix: backend | |
python-version: ${{ needs.config.outputs.PYTHON_VERSION }} | |
plone-version: ${{ needs.config.outputs.PLONE_VERSION }} | |
if: ${{ needs.config.outputs.backend == 'true' }} | |
permissions: | |
contents: read | |
packages: write | |
frontend: | |
uses: ./.github/workflows/frontend.yml | |
needs: | |
- config | |
with: | |
base-tag: ${{ needs.config.outputs.BASE_TAG }} | |
image-name-prefix: ${{ needs.config.outputs.IMAGE_NAME_PREFIX }} | |
image-name-suffix: frontend | |
node-version: ${{ needs.config.outputs.NODE_VERSION }} | |
volto-version: ${{ needs.config.outputs.VOLTO_VERSION }} | |
if: ${{ needs.config.outputs.frontend == 'true' }} | |
permissions: | |
contents: read | |
packages: write | |
deploy: | |
concurrency: deploy_testing | |
needs: [config, backend, frontend] | |
if: always() | |
timeout-minutes: 8 | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ needs.config.outputs.DEPLOY_ENVIRONMENT }} | |
url: https://${{ needs.config.outputs.DEPLOY_ENVIRONMENT }} | |
steps: | |
- name: Verify container builds | |
id: verify_image_builds | |
env: | |
NEED_BACKEND: ${{ needs.config.outputs.backend }} | |
NEED_FRONTEND: ${{ needs.config.outputs.frontend }} | |
FINISHED_BACKEND: ${{ needs.backend.result }} | |
FINISHED_FRONTEND: ${{ needs.frontend.result }} | |
GITHUB_REF: ${{ github.ref }} | |
run: | | |
if [[ "${NEED_BACKEND}" == "true" && "${FINISHED_BACKEND}" != "success" ]]; then | |
echo "::error::Backend image not built succesfully, but required for deploy" | |
exit 1 | |
fi | |
if [[ "${NEED_FRONTEND}" == "true" && "${FINISHED_FRONTEND}" != "success" ]]; then | |
echo "::error::Fontend image not built succesfully, but required for deploy" | |
exit 1 | |
fi | |
if [[ "${NEED_FRONTEND}" == "false" && "${NEED_BACKEND}" == "false" ]]; then | |
echo "::warning::Merge to main, but no deploy needed. Aborting." | |
exit 1 | |
fi | |
if [[ "${GITHUB_REF}" != "refs/heads/main" ]]; then | |
echo "::warning::No merge to main. Aborting." | |
exit 1 | |
fi | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Test vars | |
run: | | |
echo "DEPLOY_ENVIRONMENT=${{ needs.config.outputs.DEPLOY_ENVIRONMENT }}" | |
echo "PLONE_VERSION=${{ needs.config.outputs.PLONE_VERSION }}" | |
echo "VOlTO_VERSION=${{ needs.config.outputs.VOLTO_VERSION }}" | |
- name: Deploy | |
uses: kitconcept/docker-stack-deploy@v1.2.0 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
registry: 'ghcr.io' | |
username: ${{ github.actor }} | |
password: ${{ secrets.DEPLOY_GHCR_READ_TOKEN }} | |
remote_host: ${{ vars.DEPLOY_HOST }} | |
remote_port: ${{ vars.DEPLOY_PORT }} | |
remote_user: ${{ vars.DEPLOY_USER }} | |
remote_private_key: ${{ secrets.DEPLOY_SSH }} | |
stack_file: ${{ env.STACK_FILE }} | |
stack_name: ${{ env.STACK_NAME }} | |
# stack_param: container version/tag. because we don't specify it here 'latest' is used in the stack file. | |
# 'latest' is needed because one of the backend/frontend iamges was maybe not built on this base_tag | |
# Then we re-use the existing latest ;-) | |
env_file: | | |
STACK_NAME=${{ env.STACK_NAME }} | |
STACK_PREFIX=${{ env.STACK_PREFIX }} | |
PUBLIC_URL=${{ env.PUBLIC_URL }} | |
CERTRESOLVER=${{ env.CERTRESOLVER }} | |
BACKEND_IMAGE=${{ env.IMAGE_NAME_PREFIX }}-backend | |
FRONTEND_IMAGE=${{ env.IMAGE_NAME_PREFIX }}-frontend | |
DB_HOST=${{ vars.DB_HOST }} | |
DB_NAME=${{ vars.DB_NAME }} | |
DB_USER=${{ vars.DB_USER }} | |
DB_PASSWORD=${{ secrets.DB_PASSWORD }} | |
BASIC_AUTH_USER=${{ vars.BASIC_AUTH_USER }} | |
BASIC_AUTH_PASSWORD=${{ vars.BASIC_AUTH_PASSWORD }} | |
deploy_timeout: 480 |