|
| 1 | +name: demo.plone.org/next build and deploy demo |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - "frontend-next/**" |
| 9 | + - ".github/workflows/frontend.yml" |
| 10 | + - ".github/workflows/next.yml" |
| 11 | + - "devops/stacks/demo.plone.org_next.yml" |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +env: |
| 15 | + IMAGE_NAME_PREFIX: ghcr.io/plone/demo-next |
| 16 | + NODE_VERSION: "24.x" |
| 17 | + PYTHON_VERSION: "3.12" |
| 18 | + |
| 19 | +jobs: |
| 20 | + config: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + backend: ${{ steps.filter.outputs.backend }} |
| 24 | + frontend: ${{ steps.filter.outputs.frontend }} |
| 25 | + BASE_TAG: ${{ steps.vars.outputs.BASE_TAG }} |
| 26 | + IMAGE_NAME_PREFIX: ${{ env.IMAGE_NAME_PREFIX }} |
| 27 | + NODE_VERSION: ${{ env.NODE_VERSION }} |
| 28 | + PYTHON_VERSION: ${{ env.PYTHON_VERSION }} |
| 29 | + PLONE_VERSION: ${{ steps.vars.outputs.PLONE_VERSION }} |
| 30 | + VOLTO_VERSION: ${{ steps.vars.outputs.VOLTO_VERSION }} |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Compute several vars needed for the CI |
| 36 | + id: vars |
| 37 | + run: | |
| 38 | + echo "BASE_TAG=sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 39 | + echo "PLONE_VERSION=$(cat backend/version.txt)" >> $GITHUB_OUTPUT |
| 40 | + python3 -c 'import json; data = json.load(open("./frontend/mrs.developer.json")); print("VOLTO_VERSION=" + (data["core"].get("tag") or "latest"))' >> $GITHUB_OUTPUT |
| 41 | +
|
| 42 | + # - uses: dorny/paths-filter@v3 |
| 43 | + # id: filter |
| 44 | + # with: |
| 45 | + # base: scaffold_update |
| 46 | + # filters: | |
| 47 | + # backend: |
| 48 | + # - 'backend-volto/**' |
| 49 | + # - '.github/workflows/backend.yml' |
| 50 | + # frontend: |
| 51 | + # - 'frontend-next/**' |
| 52 | + # - '.github/workflows/frontend.yml' |
| 53 | + |
| 54 | + - name: Test vars |
| 55 | + run: | |
| 56 | + echo 'BASE_TAG=${{ steps.vars.outputs.BASE_TAG }}' |
| 57 | + echo 'PLONE_VERSION=${{ steps.vars.outputs.PLONE_VERSION }}' |
| 58 | + echo 'VOLTO_VERSION=${{ steps.vars.outputs.VOLTO_VERSION }}' |
| 59 | + # echo 'backend: ${{ steps.filter.outputs.backend }}' |
| 60 | + echo 'frontend: ${{ steps.filter.outputs.frontend }}' |
| 61 | +
|
| 62 | + # backend: |
| 63 | + # uses: ./.github/workflows/backend.yml |
| 64 | + # needs: |
| 65 | + # - config |
| 66 | + # with: |
| 67 | + # base-tag: ${{ needs.config.outputs.BASE_TAG }} |
| 68 | + # image-name-prefix: ${{ needs.config.outputs.IMAGE_NAME_PREFIX }} |
| 69 | + # image-name-suffix: backend |
| 70 | + # python-version: ${{ needs.config.outputs.PYTHON_VERSION }} |
| 71 | + # plone-version: ${{ needs.config.outputs.PLONE_VERSION }} |
| 72 | + # if: ${{ needs.config.outputs.backend == 'true' }} |
| 73 | + # permissions: |
| 74 | + # contents: read |
| 75 | + # packages: write |
| 76 | + |
| 77 | + frontend: |
| 78 | + uses: ./.github/workflows/frontend.yml |
| 79 | + needs: |
| 80 | + - config |
| 81 | + with: |
| 82 | + base-tag: ${{ needs.config.outputs.BASE_TAG }} |
| 83 | + image-name-prefix: ${{ needs.config.outputs.IMAGE_NAME_PREFIX }} |
| 84 | + image-name-suffix: frontend |
| 85 | + node-version: ${{ needs.config.outputs.NODE_VERSION }} |
| 86 | + volto-version: ${{ needs.config.outputs.VOLTO_VERSION }} |
| 87 | + build-dir: frontend-next/ |
| 88 | + docker-file: Dockerfile |
| 89 | + # if: ${{ needs.config.outputs.frontend == 'true' }} |
| 90 | + permissions: |
| 91 | + contents: read |
| 92 | + packages: write |
| 93 | + |
| 94 | + deploy: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + # this is overcomplicated for now, but allows us to re'add a custom backend again later |
| 97 | + #if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && !contains(needs.*.result, 'failure') }} |
| 98 | + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' |
| 99 | + needs: [config, frontend] |
| 100 | + steps: |
| 101 | + - name: Checkout |
| 102 | + uses: actions/checkout@v4 |
| 103 | + |
| 104 | + - name: Deploy to cluster |
| 105 | + uses: kitconcept/docker-stack-deploy@v1.2.0 |
| 106 | + with: |
| 107 | + registry: "ghcr.io" |
| 108 | + username: ${{ github.actor }} |
| 109 | + password: ${{ secrets.DEPLOY_GHCR_READ_TOKEN }} |
| 110 | + remote_host: ${{ vars.DEPLOY_HOST }} |
| 111 | + remote_port: ${{ vars.DEPLOY_PORT }} |
| 112 | + remote_user: ${{ vars.DEPLOY_USER }} |
| 113 | + remote_private_key: ${{ secrets.DEPLOY_SSH }} |
| 114 | + stack_file: devops/stacks/demo.plone.org_next.yml |
| 115 | + stack_name: demo-plone-org-next |
| 116 | + stack_param: latest |
| 117 | + # env_file: | |
| 118 | + # DB_PASSWORD="not used" |
| 119 | + deploy_timeout: 480 |
| 120 | + |
| 121 | + report: |
| 122 | + name: "Final report" |
| 123 | + if: ${{ always() }} |
| 124 | + runs-on: ubuntu-latest |
| 125 | + needs: |
| 126 | + - config |
| 127 | + - frontend |
| 128 | + - deploy |
| 129 | + steps: |
| 130 | + - name: Write report |
| 131 | + run: | |
| 132 | + echo '# Workflow Report' >> $GITHUB_STEP_SUMMARY |
| 133 | + echo '| Job ID | Conclusion |' >> $GITHUB_STEP_SUMMARY |
| 134 | + echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY |
| 135 | + echo '| config | ${{ needs.config.result }} |' >> $GITHUB_STEP_SUMMARY |
| 136 | + # echo '| backend | ${{ needs.backend.result }} |' >> $GITHUB_STEP_SUMMARY |
| 137 | + echo '| frontend | ${{ needs.frontend.result }} |' >> $GITHUB_STEP_SUMMARY |
0 commit comments