From 99601963f1499ec5f1f06666559e6ee59aa1075e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 5 Mar 2023 14:51:04 +0100 Subject: [PATCH 01/10] cleanup publish workflow for non-branded version --- .github/workflows/publish.yml | 451 ++++++++++++++++------------------ 1 file changed, 207 insertions(+), 244 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 32198dd62..404493d93 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,61 +4,34 @@ on: push: branches: - master - # - 5059-epic-groups # for testing while developing - # template branches in repo - # - template--separate-branch-auto-deployment--5059-epic-groups + - new-ocelot-workflows-publish-deploy jobs: - ############################################################################## - # JOB: PREPARE ############################################################### - ############################################################################## - prepare: - name: Prepare - runs-on: ubuntu-latest - # needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # TODO: DO STUFF ??? ##################################################### - ########################################################################## - - name: Check translation files - run: | - scripts/translations/sort.sh - scripts/translations/missing-keys.sh - ############################################################################## # JOB: DOCKER BUILD COMMUNITY NEO4J ########################################## ############################################################################## build_production_neo4j: name: Docker Build Production - Neo4J runs-on: ubuntu-latest - needs: [prepare] steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - name: Checkout code uses: actions/checkout@v3 - ########################################################################## - # SET ENVS ############################################################### - ########################################################################## - - name: ENV - VERSION - run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV - - name: ENV - BUILD_DATE - run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - - name: ENV - BUILD_VERSION - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - - name: ENV - BUILD_COMMIT - run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - ########################################################################## - # NEO4J ################################################################## - ########################################################################## + - name: Setup env + run: | + echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV + echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - name: Neo4J | Build `community` image - run: docker build --target community -t "ocelotsocialnetwork/neo4j-community:latest" -t "ocelotsocialnetwork/neo4j-community:${VERSION}" -t "ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT neo4j/ + run: | + docker build --target community \ + -t "ocelotsocialnetwork/neo4j-community:latest" \ + -t "ocelotsocialnetwork/neo4j-community:${VERSION}" \ + -t "ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + neo4j/ - name: Neo4J | Save docker image run: docker save "ocelotsocialnetwork/neo4j-community" > /tmp/neo4j.tar - name: Upload Artifact @@ -73,32 +46,41 @@ jobs: build_production_backend: name: Docker Build Production - Backend runs-on: ubuntu-latest - needs: [prepare] steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - name: Checkout code uses: actions/checkout@v3 - ########################################################################## - # SET ENVS ############################################################### - ########################################################################## - - name: ENV - VERSION - run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV - - name: ENV - BUILD_DATE - run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - - name: ENV - BUILD_VERSION - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - - name: ENV - BUILD_COMMIT - run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - ########################################################################## - # BUILD BACKEND DOCKER IMAGE (production) ################################ - ########################################################################## + - name: Setup env + run: | + echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV + echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - name: Backend | Build `production` image run: | - docker build --target base -t "ocelotsocialnetwork/backend:latest-base" -t "ocelotsocialnetwork/backend:${VERSION}-base" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/ - docker build --target code -t "ocelotsocialnetwork/backend:latest-code" -t "ocelotsocialnetwork/backend:${VERSION}-code" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/ - docker build --target production -t "ocelotsocialnetwork/backend:latest" -t "ocelotsocialnetwork/backend:${VERSION}" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/ + docker build --target base \ + -t "ocelotsocialnetwork/backend:latest-base" \ + -t "ocelotsocialnetwork/backend:${VERSION}-base" \ + -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-base" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + backend/ + docker build --target code \ + -t "ocelotsocialnetwork/backend:latest-code" \ + -t "ocelotsocialnetwork/backend:${VERSION}-code" \ + -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-code" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + backend/ + docker build --target production \ + -t "ocelotsocialnetwork/backend:latest" \ + -t "ocelotsocialnetwork/backend:${VERSION}" \ + -t "ocelotsocialnetwork/backend:${BUILD_VERSION}" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + backend/ - name: Backend | Save docker image run: docker save "ocelotsocialnetwork/backend" > /tmp/backend.tar - name: Upload Artifact @@ -113,32 +95,41 @@ jobs: build_production_webapp: name: Docker Build Production - WebApp runs-on: ubuntu-latest - needs: [prepare] steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - name: Checkout code uses: actions/checkout@v3 - ########################################################################## - # SET ENVS ############################################################### - ########################################################################## - - name: ENV - VERSION - run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV - - name: ENV - BUILD_DATE - run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - - name: ENV - BUILD_VERSION - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - - name: ENV - BUILD_COMMIT - run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - ########################################################################## - # BUILD WEBAPP DOCKER IMAGE (build) ###################################### - ########################################################################## + - name: Setup env + run: | + echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV + echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - name: Webapp | Build `production` image run: | - docker build --target base -t "ocelotsocialnetwork/webapp:latest-base" -t "ocelotsocialnetwork/webapp:${VERSION}-base" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ - docker build --target code -t "ocelotsocialnetwork/webapp:latest-code" -t "ocelotsocialnetwork/webapp:${VERSION}-code" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ - docker build --target production -t "ocelotsocialnetwork/webapp:latest" -t "ocelotsocialnetwork/webapp:${VERSION}" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ + docker build --target base \ + -t "ocelotsocialnetwork/webapp:latest-base" \ + -t "ocelotsocialnetwork/webapp:${VERSION}-base" \ + -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-base" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + webapp/ + docker build --target code \ + -t "ocelotsocialnetwork/webapp:latest-code" \ + -t "ocelotsocialnetwork/webapp:${VERSION}-code" \ + -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-code" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + webapp/ + docker build --target production \ + -t "ocelotsocialnetwork/webapp:latest" \ + -t "ocelotsocialnetwork/webapp:${VERSION}" \ + -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + webapp/ - name: Webapp | Save docker image run: docker save "ocelotsocialnetwork/webapp" > /tmp/webapp.tar - name: Upload Artifact @@ -153,32 +144,44 @@ jobs: build_production_maintenance: name: Docker Build Production - Maintenance runs-on: ubuntu-latest - needs: [prepare] steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - name: Checkout code uses: actions/checkout@v3 - ########################################################################## - # SET ENVS ############################################################### - ########################################################################## - - name: ENV - VERSION - run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV - - name: ENV - BUILD_DATE - run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - - name: ENV - BUILD_VERSION - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - - name: ENV - BUILD_COMMIT - run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - ########################################################################## - # BUILD MAINTENANCE DOCKER IMAGE (build) ################################# - ########################################################################## + - name: Setup env + run: | + echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV + echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - name: Maintenance | Build `production` image run: | - docker build --target base -t "ocelotsocialnetwork/maintenance:latest-base" -t "ocelotsocialnetwork/maintenance:${VERSION}-base" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance - docker build --target code -t "ocelotsocialnetwork/maintenance:latest-code" -t "ocelotsocialnetwork/maintenance:${VERSION}-code" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance - docker build --target production -t "ocelotsocialnetwork/maintenance:latest" -t "ocelotsocialnetwork/maintenance:${VERSION}" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance + docker build --target base \ + -t "ocelotsocialnetwork/maintenance:latest-base" \ + -t "ocelotsocialnetwork/maintenance:${VERSION}-base" \ + -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-base" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + -f webapp/Dockerfile.maintenance \ + webapp/ + docker build --target code \ + -t "ocelotsocialnetwork/maintenance:latest-code" \ + -t "ocelotsocialnetwork/maintenance:${VERSION}-code" \ + -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-code" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + -f webapp/Dockerfile.maintenance \ + webapp/ + docker build --target production \ + -t "ocelotsocialnetwork/maintenance:latest" \ + -t "ocelotsocialnetwork/maintenance:${VERSION}" \ + -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" \ + --build-arg BBUILD_DATE=$BUILD_DATE \ + --build-arg BBUILD_VERSION=$BUILD_VERSION \ + --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ + -f webapp/Dockerfile.maintenance \ + webapp/ - name: Maintenance | Save docker image run: docker save "ocelotsocialnetwork/maintenance" > /tmp/maintenance.tar - name: Upload Artifact @@ -198,130 +201,39 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOWNLOAD DOCKER IMAGES ################################################# - ########################################################################## - name: Download Docker Image (Neo4J) uses: actions/download-artifact@v3 with: name: docker-neo4j-community path: /tmp - - name: Load Docker Image - run: docker load < /tmp/neo4j.tar + - run: docker load < /tmp/neo4j.tar - name: Download Docker Image (Backend) uses: actions/download-artifact@v3 with: name: docker-backend-production path: /tmp - - name: Load Docker Image - run: docker load < /tmp/backend.tar + - run: docker load < /tmp/backend.tar - name: Download Docker Image (WebApp) uses: actions/download-artifact@v3 with: name: docker-webapp-production path: /tmp - - name: Load Docker Image - run: docker load < /tmp/webapp.tar + - run: docker load < /tmp/webapp.tar - name: Download Docker Image (Maintenance) uses: actions/download-artifact@v3 with: name: docker-maintenance-production path: /tmp - - name: Load Docker Image - run: docker load < /tmp/maintenance.tar - ########################################################################## - # Upload ################################################################# - ########################################################################## + - run: docker load < /tmp/maintenance.tar + - name: login to dockerhub run: echo "${DOCKERHUB_TOKEN}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin - - name: Push neo4j - run: docker push --all-tags ocelotsocialnetwork/neo4j-community - - name: Push backend - run: docker push --all-tags ocelotsocialnetwork/backend - - name: Push webapp - run: docker push --all-tags ocelotsocialnetwork/webapp - - name: Push maintenance - run: docker push --all-tags ocelotsocialnetwork/maintenance - - ############################################################################## - # JOB: KUBERNETES DEPLOY ACTUAL/LATEST VERSION ###################################### - ############################################################################## - kubernetes_deploy: - # see example https://github.com/do-community/example-doctl-action - # see example https://github.com/do-community/example-doctl-action/blob/main/.github/workflows/workflow.yaml - name: Kubernetes deploy of latest version to stage.ocelot.social cluster at DigitalOcean - runs-on: ubuntu-latest - needs: [upload_to_dockerhub] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # SET ENVS ############################################################### - ########################################################################## - - name: ENV - VERSION - run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV - - name: ENV - BUILD_VERSION - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - ########################################################################## - # Install DigitalOceans doctl and set kubeconfig ######################### - ########################################################################## - - name: Install doctl - uses: digitalocean/action-doctl@v2 - with: - token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - - name: Save DigitalOcean kubeconfig with short-lived credentials - run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 cluster-stage-ocelot-social - ########################################################################## - # Deploy new Docker images to DigitalOcean Kubernetes cluster ############ - ########################################################################## - # - name: Deploy 'latest' to DigitalOcean Kubernetes - # run: | - # kubectl -n default set image deployment/ocelot-webapp container-ocelot-webapp=ocelotsocialnetwork/webapp:latest - # kubectl -n default rollout restart deployment/ocelot-webapp - # kubectl -n default set image deployment/ocelot-backend container-ocelot-backend=ocelotsocialnetwork/backend:latest - # kubectl -n default rollout restart deployment/ocelot-backend - # kubectl -n default set image deployment/ocelot-maintenance container-ocelot-maintenance=ocelotsocialnetwork/maintenance:latest - # kubectl -n default rollout restart deployment/ocelot-maintenance - # kubectl -n default set image deployment/ocelot-neo4j container-ocelot-neo4j=ocelotsocialnetwork/neo4j-community:latest - # kubectl -n default rollout restart deployment/ocelot-neo4j - - name: Deploy actual version '$BUILD_VERSION' to DigitalOcean Kubernetes + - name: Push images run: | - kubectl -n default set image deployment/ocelot-webapp container-ocelot-webapp=ocelotsocialnetwork/webapp:$BUILD_VERSION - kubectl -n default rollout restart deployment/ocelot-webapp - kubectl -n default set image deployment/ocelot-backend container-ocelot-backend=ocelotsocialnetwork/backend:$BUILD_VERSION - kubectl -n default rollout restart deployment/ocelot-backend - kubectl -n default set image deployment/ocelot-maintenance container-ocelot-maintenance=ocelotsocialnetwork/maintenance:$BUILD_VERSION - kubectl -n default rollout restart deployment/ocelot-maintenance - kubectl -n default set image deployment/ocelot-neo4j container-ocelot-neo4j=ocelotsocialnetwork/neo4j-community:$BUILD_VERSION - kubectl -n default rollout restart deployment/ocelot-neo4j - # because this step 'kubectl -n default rollout status deployment/* --timeout=600s' does not work as expected - # and we need the pods to be up again for cleaning and seeding the Neo4j database and the backend. - # !!! this is not a perfect solution !!! - # deployments are regularly up again after 3 minutes and 10 seconds - - name: Sleep for 4 minutes, means 240 seconds - run: sleep 240s - shell: bash - - name: Verify deployment and wait for the pods of each deployment to get ready for cleaning and seeding of the database - run: | - kubectl -n default rollout status deployment/ocelot-backend --timeout=600s - kubectl -n default rollout status deployment/ocelot-neo4j --timeout=600s - kubectl -n default rollout status deployment/ocelot-maintenance --timeout=600s - kubectl -n default rollout status deployment/ocelot-webapp --timeout=600s - - name: Run migrations for Neo4j database via backend for staging - run: | - kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "yarn prod:migrate up" - - name: Reset and seed Neo4j database via backend for staging - # db cleaning and seeding is only possible in production if env 'PRODUCTION_DB_CLEAN_ALLOW=true' is set in deployment - run: | - kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "node --experimental-repl-await dist/db/clean.js && node --experimental-repl-await dist/db/seed.js" + docker push --all-tags ocelotsocialnetwork/neo4j-community + docker push --all-tags ocelotsocialnetwork/backend + docker push --all-tags ocelotsocialnetwork/webapp + docker push --all-tags ocelotsocialnetwork/maintenance ############################################################################## # JOB: GITHUB TAG LATEST VERSION ############################################# @@ -331,39 +243,16 @@ jobs: runs-on: ubuntu-latest needs: [upload_to_dockerhub] steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 # Fetch full History for changelog - ########################################################################## - # SET ENVS ############################################################### - ########################################################################## - - name: ENV - VERSION - run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV - - name: ENV - BUILD_DATE - run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - - name: ENV - BUILD_VERSION - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - - name: ENV - BUILD_COMMIT - run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - ########################################################################## - # Push version tag to GitHub ############################################# - ########################################################################## - # TODO: this will error on duplicate - #- name: package-version-to-git-tag - # uses: pkgdeps/git-tag-action@v2 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # github_repo: ${{ github.repository }} - # version: ${{ env.VERSION }} - # git_commit_sha: ${{ github.sha }} - # git_tag_prefix: "v" - ########################################################################## - # Push build tag to GitHub ############################################### - ########################################################################## + - name: Setup env + run: | + echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV + echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV - name: package-version-to-git-tag + build number uses: pkgdeps/git-tag-action@v2 with: @@ -371,14 +260,13 @@ jobs: github_repo: ${{ github.repository }} version: ${{ env.BUILD_VERSION }} git_commit_sha: ${{ github.sha }} - git_tag_prefix: "b" - ########################################################################## - # Push release tag to GitHub ############################################# - ########################################################################## - - name: yarn install - run: yarn install - - name: generate changelog - run: yarn auto-changelog --latest-version ${{ env.VERSION }} --unreleased-only + #git_tag_prefix: "b" + # TODO + git_tag_prefix: "test" + - name: Generate changelog + run: | + yarn install + yarn auto-changelog --latest-version ${{ env.VERSION }} --unreleased-only - name: package-version-to-git-release continue-on-error: true # Will fail if tag exists id: create_release @@ -391,3 +279,78 @@ jobs: body_path: ./CHANGELOG.md draft: false prerelease: false + + # ############################################################################## + # # JOB: KUBERNETES DEPLOY ACTUAL/LATEST VERSION ###################################### + # ############################################################################## + # kubernetes_deploy: + # # see example https://github.com/do-community/example-doctl-action + # # see example https://github.com/do-community/example-doctl-action/blob/main/.github/workflows/workflow.yaml + # name: Kubernetes deploy of latest version to stage.ocelot.social cluster at DigitalOcean + # runs-on: ubuntu-latest + # needs: [upload_to_dockerhub] + # steps: + # ########################################################################## + # # CHECKOUT CODE ########################################################## + # ########################################################################## + # - name: Checkout code + # uses: actions/checkout@v3 + # ########################################################################## + # # SET ENVS ############################################################### + # ########################################################################## + # - name: ENV - VERSION + # run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV + # - name: ENV - BUILD_VERSION + # run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + # ########################################################################## + # # Install DigitalOceans doctl and set kubeconfig ######################### + # ########################################################################## + # - name: Install doctl + # uses: digitalocean/action-doctl@v2 + # with: + # token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + # - name: Save DigitalOcean kubeconfig with short-lived credentials + # run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 cluster-stage-ocelot-social + # ########################################################################## + # # Deploy new Docker images to DigitalOcean Kubernetes cluster ############ + # ########################################################################## + # # - name: Deploy 'latest' to DigitalOcean Kubernetes + # # run: | + # # kubectl -n default set image deployment/ocelot-webapp container-ocelot-webapp=ocelotsocialnetwork/webapp:latest + # # kubectl -n default rollout restart deployment/ocelot-webapp + # # kubectl -n default set image deployment/ocelot-backend container-ocelot-backend=ocelotsocialnetwork/backend:latest + # # kubectl -n default rollout restart deployment/ocelot-backend + # # kubectl -n default set image deployment/ocelot-maintenance container-ocelot-maintenance=ocelotsocialnetwork/maintenance:latest + # # kubectl -n default rollout restart deployment/ocelot-maintenance + # # kubectl -n default set image deployment/ocelot-neo4j container-ocelot-neo4j=ocelotsocialnetwork/neo4j-community:latest + # # kubectl -n default rollout restart deployment/ocelot-neo4j + # - name: Deploy actual version '$BUILD_VERSION' to DigitalOcean Kubernetes + # run: | + # kubectl -n default set image deployment/ocelot-webapp container-ocelot-webapp=ocelotsocialnetwork/webapp:$BUILD_VERSION + # kubectl -n default rollout restart deployment/ocelot-webapp + # kubectl -n default set image deployment/ocelot-backend container-ocelot-backend=ocelotsocialnetwork/backend:$BUILD_VERSION + # kubectl -n default rollout restart deployment/ocelot-backend + # kubectl -n default set image deployment/ocelot-maintenance container-ocelot-maintenance=ocelotsocialnetwork/maintenance:$BUILD_VERSION + # kubectl -n default rollout restart deployment/ocelot-maintenance + # kubectl -n default set image deployment/ocelot-neo4j container-ocelot-neo4j=ocelotsocialnetwork/neo4j-community:$BUILD_VERSION + # kubectl -n default rollout restart deployment/ocelot-neo4j + # # because this step 'kubectl -n default rollout status deployment/* --timeout=600s' does not work as expected + # # and we need the pods to be up again for cleaning and seeding the Neo4j database and the backend. + # # !!! this is not a perfect solution !!! + # # deployments are regularly up again after 3 minutes and 10 seconds + # - name: Sleep for 4 minutes, means 240 seconds + # run: sleep 240s + # shell: bash + # - name: Verify deployment and wait for the pods of each deployment to get ready for cleaning and seeding of the database + # run: | + # kubectl -n default rollout status deployment/ocelot-backend --timeout=600s + # kubectl -n default rollout status deployment/ocelot-neo4j --timeout=600s + # kubectl -n default rollout status deployment/ocelot-maintenance --timeout=600s + # kubectl -n default rollout status deployment/ocelot-webapp --timeout=600s + # - name: Run migrations for Neo4j database via backend for staging + # run: | + # kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "yarn prod:migrate up" + # - name: Reset and seed Neo4j database via backend for staging + # # db cleaning and seeding is only possible in production if env 'PRODUCTION_DB_CLEAN_ALLOW=true' is set in deployment + # run: | + # kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "node --experimental-repl-await dist/db/clean.js && node --experimental-repl-await dist/db/seed.js" \ No newline at end of file From d271ff37604be4a306e65774124cc086fbe85625 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 5 Mar 2023 15:00:10 +0100 Subject: [PATCH 02/10] use long version of docker build flags --- .github/workflows/publish.yml | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 404493d93..519875507 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,9 +25,9 @@ jobs: - name: Neo4J | Build `community` image run: | docker build --target community \ - -t "ocelotsocialnetwork/neo4j-community:latest" \ - -t "ocelotsocialnetwork/neo4j-community:${VERSION}" \ - -t "ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}" \ + --tag "ocelotsocialnetwork/neo4j-community:latest" \ + --tag "ocelotsocialnetwork/neo4j-community:${VERSION}" \ + --tag "ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ @@ -58,25 +58,25 @@ jobs: - name: Backend | Build `production` image run: | docker build --target base \ - -t "ocelotsocialnetwork/backend:latest-base" \ - -t "ocelotsocialnetwork/backend:${VERSION}-base" \ - -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-base" \ + --tag "ocelotsocialnetwork/backend:latest-base" \ + --tag "ocelotsocialnetwork/backend:${VERSION}-base" \ + --tag "ocelotsocialnetwork/backend:${BUILD_VERSION}-base" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ backend/ docker build --target code \ - -t "ocelotsocialnetwork/backend:latest-code" \ - -t "ocelotsocialnetwork/backend:${VERSION}-code" \ - -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-code" \ + --tag "ocelotsocialnetwork/backend:latest-code" \ + --tag "ocelotsocialnetwork/backend:${VERSION}-code" \ + --tag "ocelotsocialnetwork/backend:${BUILD_VERSION}-code" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ backend/ docker build --target production \ - -t "ocelotsocialnetwork/backend:latest" \ - -t "ocelotsocialnetwork/backend:${VERSION}" \ - -t "ocelotsocialnetwork/backend:${BUILD_VERSION}" \ + --tag "ocelotsocialnetwork/backend:latest" \ + --tag "ocelotsocialnetwork/backend:${VERSION}" \ + --tag "ocelotsocialnetwork/backend:${BUILD_VERSION}" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ @@ -107,25 +107,25 @@ jobs: - name: Webapp | Build `production` image run: | docker build --target base \ - -t "ocelotsocialnetwork/webapp:latest-base" \ - -t "ocelotsocialnetwork/webapp:${VERSION}-base" \ - -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-base" \ + --tag "ocelotsocialnetwork/webapp:latest-base" \ + --tag "ocelotsocialnetwork/webapp:${VERSION}-base" \ + --tag "ocelotsocialnetwork/webapp:${BUILD_VERSION}-base" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ webapp/ docker build --target code \ - -t "ocelotsocialnetwork/webapp:latest-code" \ - -t "ocelotsocialnetwork/webapp:${VERSION}-code" \ - -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-code" \ + --tag "ocelotsocialnetwork/webapp:latest-code" \ + --tag "ocelotsocialnetwork/webapp:${VERSION}-code" \ + --tag "ocelotsocialnetwork/webapp:${BUILD_VERSION}-code" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ webapp/ docker build --target production \ - -t "ocelotsocialnetwork/webapp:latest" \ - -t "ocelotsocialnetwork/webapp:${VERSION}" \ - -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}" \ + --tag "ocelotsocialnetwork/webapp:latest" \ + --tag "ocelotsocialnetwork/webapp:${VERSION}" \ + --tag "ocelotsocialnetwork/webapp:${BUILD_VERSION}" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ @@ -156,27 +156,27 @@ jobs: - name: Maintenance | Build `production` image run: | docker build --target base \ - -t "ocelotsocialnetwork/maintenance:latest-base" \ - -t "ocelotsocialnetwork/maintenance:${VERSION}-base" \ - -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-base" \ + --tag "ocelotsocialnetwork/maintenance:latest-base" \ + --tag "ocelotsocialnetwork/maintenance:${VERSION}-base" \ + --tag "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-base" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ -f webapp/Dockerfile.maintenance \ webapp/ docker build --target code \ - -t "ocelotsocialnetwork/maintenance:latest-code" \ - -t "ocelotsocialnetwork/maintenance:${VERSION}-code" \ - -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-code" \ + --tag "ocelotsocialnetwork/maintenance:latest-code" \ + --tag "ocelotsocialnetwork/maintenance:${VERSION}-code" \ + --tag "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-code" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ -f webapp/Dockerfile.maintenance \ webapp/ docker build --target production \ - -t "ocelotsocialnetwork/maintenance:latest" \ - -t "ocelotsocialnetwork/maintenance:${VERSION}" \ - -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" \ + --tag "ocelotsocialnetwork/maintenance:latest" \ + --tag "ocelotsocialnetwork/maintenance:${VERSION}" \ + --tag "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ From 71dc31d926a561f928c74ac9146963412053a885 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 5 Mar 2023 15:02:10 +0100 Subject: [PATCH 03/10] try different quotations --- .github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 519875507..3660d3b5a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,9 +25,9 @@ jobs: - name: Neo4J | Build `community` image run: | docker build --target community \ - --tag "ocelotsocialnetwork/neo4j-community:latest" \ - --tag "ocelotsocialnetwork/neo4j-community:${VERSION}" \ - --tag "ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}" \ + --tag 'ocelotsocialnetwork/neo4j-community:latest' \ + --tag 'ocelotsocialnetwork/neo4j-community:${VERSION}'' \ + --tag 'ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}'' \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ From 62e3b3042790b41ee16dc40b1aac168188e58aee Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 5 Mar 2023 15:03:57 +0100 Subject: [PATCH 04/10] no quotations --- .github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3660d3b5a..9d10bbbbd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,9 +25,9 @@ jobs: - name: Neo4J | Build `community` image run: | docker build --target community \ - --tag 'ocelotsocialnetwork/neo4j-community:latest' \ - --tag 'ocelotsocialnetwork/neo4j-community:${VERSION}'' \ - --tag 'ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}'' \ + --tag ocelotsocialnetwork/neo4j-community:latest \ + --tag ocelotsocialnetwork/neo4j-community:${VERSION} \ + --tag ocelotsocialnetwork/neo4j-community:${BUILD_VERSION} \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ From 540c3bd9c40c3b42267baa9b6f4601a2d1066367 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 5 Mar 2023 15:07:32 +0100 Subject: [PATCH 05/10] referencing envs in a second step --- .github/workflows/publish.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9d10bbbbd..3b7fdaf60 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,14 +20,14 @@ jobs: run: | echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - name: Neo4J | Build `community` image run: | docker build --target community \ - --tag ocelotsocialnetwork/neo4j-community:latest \ - --tag ocelotsocialnetwork/neo4j-community:${VERSION} \ - --tag ocelotsocialnetwork/neo4j-community:${BUILD_VERSION} \ + --tag "ocelotsocialnetwork/neo4j-community:latest" \ + --tag "ocelotsocialnetwork/neo4j-community:${VERSION}" \ + --tag "ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}" \ --build-arg BBUILD_DATE=$BUILD_DATE \ --build-arg BBUILD_VERSION=$BUILD_VERSION \ --build-arg BBUILD_COMMIT=$BUILD_COMMIT \ @@ -53,8 +53,8 @@ jobs: run: | echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - name: Backend | Build `production` image run: | docker build --target base \ @@ -102,8 +102,8 @@ jobs: run: | echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - name: Webapp | Build `production` image run: | docker build --target base \ @@ -151,8 +151,8 @@ jobs: run: | echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - name: Maintenance | Build `production` image run: | docker build --target base \ @@ -251,8 +251,8 @@ jobs: run: | echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV - echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - name: package-version-to-git-tag + build number uses: pkgdeps/git-tag-action@v2 with: From baedff2f9475514d181612757450891db813cebf Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Mar 2023 10:53:23 +0100 Subject: [PATCH 06/10] use trigger to call other workflow --- .github/workflows/publish-branded.yml | 25 ++++++------------------- .github/workflows/publish.yml | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/workflows/publish-branded.yml b/.github/workflows/publish-branded.yml index 2877aa213..e9dc62751 100644 --- a/.github/workflows/publish-branded.yml +++ b/.github/workflows/publish-branded.yml @@ -1,9 +1,7 @@ -name: ocelot.social publish branded CI - +name: publish-branded on: - push: - branches: - - master + repository_dispatch: + types: [trigger_build_success] jobs: build_branded: name: Docker Build Branded @@ -11,7 +9,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - + with: + ref: ${{ github.event.client_payload.ref }} - name: Build branded images run: | deployment/scripts/branded-images.build.sh @@ -45,9 +44,6 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Download Docker Image (Backend) uses: actions/download-artifact@v2 with: @@ -73,13 +69,4 @@ jobs: run: docker load < /tmp/maintenance-branded.tar - name: Upload to dockerhub - run: deployment/scripts/branded-images.upload.sh -# - name: login to dockerhub -# run: echo "${DOCKERHUB_TOKEN}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin -# -# - name: Push Backend -# run: docker push --all-tags ocelotsocialnetwork/backend-branded -# - name: Push Webapp -# run: docker push --all-tags ocelotsocialnetwork/webapp-branded -# - name: Push Maintenance -# run: docker push --all-tags ocelotsocialnetwork/maintenance-branded \ No newline at end of file + run: deployment/scripts/branded-images.upload.sh \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3b7fdaf60..f9d3f0ecb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: ocelot.social publish CI +name: publish on: push: @@ -280,6 +280,26 @@ jobs: draft: false prerelease: false + build_trigger: + name: Trigger successful build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch full History for changelog + - name: Setup env + run: | + echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV + echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV + - run: echo "BUILD_VERSION=${VERSION}-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@v1 + with: + event-type: trigger_build_success + client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "VERSION": "${VERSION}", "BUILD_DATE": "${BUILD_DATE}", "BUILD_COMMIT": "${BUILD_COMMIT}", "BUILD_VERSION": "${BUILD_VERSION}"}' + # ############################################################################## # # JOB: KUBERNETES DEPLOY ACTUAL/LATEST VERSION ###################################### # ############################################################################## From 8e407917736d3b75cc1786abb49a6015e46cbe3c Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Mar 2023 11:01:25 +0100 Subject: [PATCH 07/10] pat token, dependance on compylete publish --- .github/workflows/publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f9d3f0ecb..28b39ad62 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -283,6 +283,7 @@ jobs: build_trigger: name: Trigger successful build runs-on: ubuntu-latest + needs: [github_tag] steps: - name: Checkout code uses: actions/checkout@v3 @@ -297,6 +298,7 @@ jobs: - name: Repository Dispatch uses: peter-evans/repository-dispatch@v1 with: + token: ${{ secrets.PAT }} event-type: trigger_build_success client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "VERSION": "${VERSION}", "BUILD_DATE": "${BUILD_DATE}", "BUILD_COMMIT": "${BUILD_COMMIT}", "BUILD_VERSION": "${BUILD_VERSION}"}' From 9bc95908aec377fa9a52cc5ad309bb708d787a62 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Mar 2023 11:39:39 +0100 Subject: [PATCH 08/10] use github token explicitly, use explicit ocelot version in brad --- .github/workflows/publish-branded.yml | 2 ++ .github/workflows/publish.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-branded.yml b/.github/workflows/publish-branded.yml index e9dc62751..90bd0607e 100644 --- a/.github/workflows/publish-branded.yml +++ b/.github/workflows/publish-branded.yml @@ -11,6 +11,8 @@ jobs: uses: actions/checkout@v2 with: ref: ${{ github.event.client_payload.ref }} + - name: Setup env + run: echo "OCELOT_VERSION=${{ github.event.client_payload.BUILD_VERSION }}" >> $GITHUB_ENV - name: Build branded images run: | deployment/scripts/branded-images.build.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 28b39ad62..67ae4d527 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -298,7 +298,7 @@ jobs: - name: Repository Dispatch uses: peter-evans/repository-dispatch@v1 with: - token: ${{ secrets.PAT }} + token: ${{ github.token }} event-type: trigger_build_success client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "VERSION": "${VERSION}", "BUILD_DATE": "${BUILD_DATE}", "BUILD_COMMIT": "${BUILD_COMMIT}", "BUILD_VERSION": "${BUILD_VERSION}"}' From 4bfba1983f81e6e0a7dfcfc4ba7a49728568d5c5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Mar 2023 12:37:20 +0100 Subject: [PATCH 09/10] define repo and refacor event name --- .github/workflows/publish-branded.yml | 2 +- .github/workflows/publish.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-branded.yml b/.github/workflows/publish-branded.yml index 90bd0607e..a404453e6 100644 --- a/.github/workflows/publish-branded.yml +++ b/.github/workflows/publish-branded.yml @@ -1,7 +1,7 @@ name: publish-branded on: repository_dispatch: - types: [trigger_build_success] + types: [trigger-build-success] jobs: build_branded: name: Docker Build Branded diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 67ae4d527..0fa7ef040 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -299,7 +299,8 @@ jobs: uses: peter-evans/repository-dispatch@v1 with: token: ${{ github.token }} - event-type: trigger_build_success + event-type: trigger-build-success + repository: ${{ github.repository }} client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "VERSION": "${VERSION}", "BUILD_DATE": "${BUILD_DATE}", "BUILD_COMMIT": "${BUILD_COMMIT}", "BUILD_VERSION": "${BUILD_VERSION}"}' # ############################################################################## From 63e519428c2298e52024bb96a193b5e9764ecece Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 6 Mar 2023 12:38:17 +0100 Subject: [PATCH 10/10] publish only on master & build tag prefix --- .github/workflows/publish.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0fa7ef040..01256d719 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - new-ocelot-workflows-publish-deploy jobs: ############################################################################## @@ -260,9 +259,7 @@ jobs: github_repo: ${{ github.repository }} version: ${{ env.BUILD_VERSION }} git_commit_sha: ${{ github.sha }} - #git_tag_prefix: "b" - # TODO - git_tag_prefix: "test" + git_tag_prefix: "b" - name: Generate changelog run: | yarn install