diff --git a/.github/workflows/container-publish.yml b/.github/workflows/container-publish.yml new file mode 100644 index 00000000..9182e34d --- /dev/null +++ b/.github/workflows/container-publish.yml @@ -0,0 +1,19 @@ +name: 'Container: Publish Image' + +on: + push: + tags: [ 'v*' ] + +permissions: + contents: write + packages: write + +jobs: + container-publish: + + runs-on: ubuntu-latest + steps: + + - uses: EmergencePlatform/php-runtime@github-actions/build-site-container/v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml new file mode 100644 index 00000000..c9e4720d --- /dev/null +++ b/.github/workflows/preview-deploy.yml @@ -0,0 +1,29 @@ +name: 'Preview: Deploy' + +on: + pull_request: + branches: [ develop ] + types: [ opened, reopened, synchronize ] + push: + branches: [ develop ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + packages: write + +jobs: + preview-deploy: + runs-on: ubuntu-latest + steps: + + - uses: EmergencePlatform/php-runtime@github-actions/deploy-site-preview/develop + id: deploy-site-preview + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + kube-config: ${{ secrets.KUBECONFIG_BASE64 }} + kube-namespace: laddr + kube-hostname: laddr.sandbox.k8s.phl.io diff --git a/.github/workflows/release-deploy.yml b/.github/workflows/release-deploy.yml deleted file mode 100644 index 4b103433..00000000 --- a/.github/workflows/release-deploy.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: 'Release: Deploy PR' - -on: - pull_request: - branches: [ 'releases/v*' ] - types: [ closed ] - -env: - DOCKER_REGISTRY: ghcr.io - DOCKER_PACKAGE: site-composite - - HAB_LICENSE: accept-no-persist - -jobs: - release-deploy: - - if: github.event.pull_request.merged == true # only run on PR merge - runs-on: ubuntu-latest - steps: - - - name: Configure release - run: | - PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH) - PR_BODY=$(jq -r ".pull_request.body" $GITHUB_EVENT_PATH) - RELEASE_TAG=$(echo "${PR_TITLE}" | grep -oP "(?<=^Release: )v\d+\.\d+\.\d+(-rc\.\d+)?$") - - if [[ "${RELEASE_TAG}" =~ -rc\.[0-9]+$ ]]; then - RELEASE_PRERELEASE=true - else - RELEASE_PRERELEASE=false - fi - - echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV - echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV - echo "RELEASE_PRERELEASE=${RELEASE_PRERELEASE}" >> $GITHUB_ENV - - echo 'PR_BODY<> $GITHUB_ENV - echo "${PR_BODY}" >> $GITHUB_ENV - echo 'END_OF_PR_BODY' >> $GITHUB_ENV - - DOCKER_REPOSITORY="${GITHUB_REPOSITORY,,}" - echo "Using DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" - echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV - - DOCKER_TAG="${RELEASE_TAG:1}" - echo "Using DOCKER_TAG=${DOCKER_TAG}" - echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV - - - name: 'Initialize Chef Habitat environment' - uses: JarvusInnovations/habitat-action@action/v1 - with: - deps: | - jarvus/hologit - - - uses: actions/checkout@v2 - - - id: site-projection - name: 'Project holobranch: emergence-site' - uses: JarvusInnovations/hologit@actions/projector/v1 - with: - # use HEAD checked out above by checkout action - ref: HEAD - fetch: false - holobranch: emergence-site - - - name: Build & push Docker image - uses: whoan/docker-build-with-cache-action@v5 - with: - dockerfile: Dockerfile - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - registry: ${{ env.DOCKER_REGISTRY }} - image_name: ${{ env.DOCKER_REPOSITORY }}/${{ env.DOCKER_PACKAGE }} - image_tag: ${{ env.DOCKER_TAG }} - build_extra_args: | - --build-arg=SITE_TREE=${{ steps.site-projection.outputs.tree }} - --build-arg=SITE_VERSION=${{ env.RELEASE_TAG }} - --build-arg=SOURCE_COMMIT=${{ github.sha }} - --build-arg=SOURCE_TAG=${{ env.RELEASE_TAG }} - --build-arg=HAB_LICENSE=${{ env.HAB_LICENSE }} - - - name: Create release - uses: ncipollo/release-action@v1 - with: - token: ${{ secrets.BOT_GITHUB_TOKEN }} - commit: '${{ github.sha }}' - tag: '${{ env.RELEASE_TAG }}' - body: '${{ env.PR_BODY }}' - draft: false - prerelease: ${{ env.RELEASE_PRERELEASE }} diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml index 2023ee47..3b5608d8 100644 --- a/.github/workflows/release-prepare.yml +++ b/.github/workflows/release-prepare.yml @@ -4,10 +4,9 @@ on: push: branches: [ develop ] -env: - GITHUB_USERNAME: codeforphilly-bot - GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} - RELEASE_BRANCH: releases/v3 +permissions: + contents: read + pull-requests: write jobs: release-prepare: @@ -15,100 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: JarvusInnovations/infra-components@channels/github-actions/release-prepare/latest with: - fetch-depth: 0 - - # - uses: mxschmitt/action-tmate@v3 - - - name: Create/update pull request - run: | - # get latest release tag - latest_release=$(git describe --tags --abbrev=0 "origin/${RELEASE_BRANCH}") - latest_release_bumped=$(echo $latest_release | awk -F. -v OFS=. '{$NF++;print}') - - - # create or update PR - pr_body="$(cat < /tmp/pr.json - pr_number=$(hub pr list -h develop -f '%I') - echo "Opened PR #${pr_number}" - fi - - - # build changelog - commits=$( - git log \ - --first-parent \ - --reverse \ - --format="%H" \ - "origin/${RELEASE_BRANCH}..develop" - ) - - changelog=() - - while read -r commit; do - subject="$(git show -s --format=%s "${commit}")" - line="" - - if [[ "${subject}" =~ Merge\ pull\ request\ \#([0-9]+) ]]; then - line="$(hub pr show -f '%t [%i] @%au' "${BASH_REMATCH[1]}" || true)" - fi - - if [ -z "${line}" ]; then - author="$(hub api "/repos/${GITHUB_REPOSITORY}/commits/${commit}" -H Accept:application/vnd.github.v3+json | jq -r '.author.login')" - if [ -n "${author}" ]; then - author="@${author}" - else - author="$(git show -s --format=%ae "${commit}")" - fi - - line="${subject} ${author}" - fi - - # move ticket number prefix into to existing square brackets at end - line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*\[([^]]+)\]\s*(\S+)$/\2 [\3, \1] \4/')" - - # move ticket number prefix into to new square brackets at end - line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*(\S+)$/\2 [\1] \3/')" - - # combine doubled square brackets at the end - line="$(echo "${line}" | perl -pe 's/^\s*(.*?)\s*\[([A-Z]+-[0-9]+)\]\s*\[([^]]+)\]\s*(\S+)$/\1 [\3, \2] \4/')" - - changelog+=("- ${line}") - done <<< "${commits}" - - - # create or update comment - comment_body="$(cat <> $GITHUB_ENV - else - echo 'PR title must match format "Release: vX.Y.Z(-rc.#)?"' - exit 1 - fi - - # check that tag doesn't exist - if git ls-remote --exit-code "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" "refs/tags/${RELEASE_TAG}"; then - echo "The PR title's version exists already" - exit 1 - fi + - uses: JarvusInnovations/infra-components@channels/github-actions/release-validate/latest + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.holo/branches/docs-site/_laddr.toml b/.holo/branches/docs-site/_laddr.toml index ea92412d..419e5324 100644 --- a/.holo/branches/docs-site/_laddr.toml +++ b/.holo/branches/docs-site/_laddr.toml @@ -1,5 +1,5 @@ [holomapping] +root = "docs" files = [ - "docs/**", "mkdocs.*.yml" ] diff --git a/.holo/branches/docs-site/docs/_laddr.toml b/.holo/branches/docs-site/docs/_laddr.toml new file mode 100644 index 00000000..9ae1579f --- /dev/null +++ b/.holo/branches/docs-site/docs/_laddr.toml @@ -0,0 +1,6 @@ +[holomapping] +root = "docs" +files = [ + "**", + "!mkdocs.*.yml", +] diff --git a/.holo/sources/skeleton-v2.toml b/.holo/sources/skeleton-v2.toml index 24dd2d58..dffea731 100644 --- a/.holo/sources/skeleton-v2.toml +++ b/.holo/sources/skeleton-v2.toml @@ -1,3 +1,3 @@ [holosource] url = "https://github.com/JarvusInnovations/emergence-skeleton-v2" -ref = "refs/tags/v2.11.2" +ref = "refs/tags/v2.12.4" diff --git a/.studiorc b/.studiorc deleted file mode 100644 index 34365507..00000000 --- a/.studiorc +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# install dependent studios -hab pkg install emergence/studio jarvus/mkdocs-studio - - -# disable studios printing their own help -export STUDIO_NOHELP="yes" - - -# load emergence studio -source "$(hab pkg path emergence/studio)/studio.sh" - -# load mkdocs studio -export DOCS_HOLOBRANCH="docs-site" -export DOCS_PARENT_SOURCE="skeleton-v2" -source "$(hab pkg path jarvus/mkdocs-studio)/studio.sh" - - -# declare shortcuts for this repository's applications - - -## final init and output -studio-help - - -# final blank line -echo diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c98b8f7c..00000000 --- a/Dockerfile +++ /dev/null @@ -1,74 +0,0 @@ -# This Dockerfile is hyper-optimized to minimize layer changes - -FROM jarvus/habitat-compose:latest as habitat - -ARG HAB_LICENSE=no-accept -ENV HAB_LICENSE=$HAB_LICENSE -ENV STUDIO_TYPE=Dockerfile -ENV HAB_ORIGIN=codeforphilly -RUN hab origin key generate - -# pre-layer all external runtime plan deps -COPY habitat/plan.sh /habitat/plan.sh -RUN hab pkg install \ - core/bash \ - emergence/php-runtime \ - $({ cat '/habitat/plan.sh' && echo && echo 'echo "${pkg_deps[@]/$pkg_origin\/*/}"'; } | hab pkg exec core/bash bash) \ - && hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/ - -# pre-layer all external runtime composite deps -COPY habitat/composite/plan.sh /habitat/composite/plan.sh -RUN hab pkg install \ - jarvus/habitat-compose \ - emergence/nginx \ - $({ cat '/habitat/composite/plan.sh' && echo && echo 'echo "${pkg_deps[@]/$pkg_origin\/*/} ${composite_mysql_pkg}"'; } | hab pkg exec core/bash bash) \ - && hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/ - - -FROM habitat as projector - -# pre-layer all build-time plan deps -RUN hab pkg install \ - core/hab-plan-build \ - jarvus/hologit \ - jarvus/toml-merge \ - $({ cat '/habitat/plan.sh' && echo && echo 'echo "${pkg_build_deps[@]/$pkg_origin\/*/}"'; } | hab pkg exec core/bash bash) \ - && hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/ - -# pre-layer all build-time composite deps -RUN hab pkg install \ - jarvus/toml-merge \ - $({ cat '/habitat/composite/plan.sh' && echo && echo 'echo "${pkg_build_deps[@]/$pkg_origin\/*/}"'; } | hab pkg exec core/bash bash) \ - && hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/ - -# build application -COPY . /src -ARG SITE_TREE -ENV SITE_TREE=$SITE_TREE -ARG SITE_VERSION -ENV SITE_VERSION=$SITE_VERSION -RUN hab pkg exec core/hab-plan-build hab-plan-build /src -RUN hab pkg exec core/hab-plan-build hab-plan-build /src/habitat/composite - - -FROM habitat as runtime - -# configure persistent volumes -RUN hab pkg exec core/coreutils mkdir -p '/hab/svc/mysql/data' '/hab/svc/site/data' '/hab/svc/nginx/files' \ - && hab pkg exec core/coreutils chown hab:hab -R '/hab/svc/mysql/data' '/hab/svc/site/data' '/hab/svc/nginx/files' - -# configure entrypoint -VOLUME ["/hab/svc/mysql/data", "/hab/svc/site/data", "/hab/svc/nginx/files"] -ENTRYPOINT ["hab", "sup", "run"] -CMD ["codeforphilly/site-composite"] - -# install .hart artifact from builder stage -COPY --from=projector /hab/cache/artifacts/$HAB_ORIGIN-* /hab/cache/artifacts/ -RUN hab pkg install /hab/cache/artifacts/$HAB_ORIGIN-* \ - && hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/ - -# add source metadata to environment -ARG SOURCE_TAG -ENV SOURCE_TAG=$SOURCE_TAG -ARG SOURCE_COMMIT -ENV SOURCE_COMMIT=$SOURCE_COMMIT diff --git a/mkdocs.repo.yml b/docs/mkdocs.repo.yml similarity index 100% rename from mkdocs.repo.yml rename to docs/mkdocs.repo.yml diff --git a/mkdocs.site.yml b/docs/mkdocs.site.yml similarity index 100% rename from mkdocs.site.yml rename to docs/mkdocs.site.yml diff --git a/mkdocs.studio.yml b/docs/mkdocs.studio.yml similarity index 100% rename from mkdocs.studio.yml rename to docs/mkdocs.studio.yml diff --git a/habitat/composite/default.toml b/habitat/composite/default.toml deleted file mode 100644 index 0ac11b57..00000000 --- a/habitat/composite/default.toml +++ /dev/null @@ -1,2 +0,0 @@ -[services.app.config] - default_timezone = "America/New_York" diff --git a/habitat/composite/plan.sh b/habitat/composite/plan.sh deleted file mode 100644 index c7ed7f9d..00000000 --- a/habitat/composite/plan.sh +++ /dev/null @@ -1,10 +0,0 @@ -composite_app_pkg_name=site -pkg_name="${composite_app_pkg_name}-composite" -pkg_origin=codeforphilly -pkg_maintainer="Code for Philly " -pkg_scaffolding=emergence/scaffolding-composite -composite_mysql_pkg=core/mysql - -pkg_version() { - scaffolding_detect_pkg_version -} diff --git a/habitat/default.toml b/habitat/default.toml deleted file mode 100644 index 8a7b2a14..00000000 --- a/habitat/default.toml +++ /dev/null @@ -1,2 +0,0 @@ -[sites.default] -database = "laddr" diff --git a/habitat/plan.sh b/habitat/plan.sh deleted file mode 100644 index 8beddd65..00000000 --- a/habitat/plan.sh +++ /dev/null @@ -1,8 +0,0 @@ -pkg_name=site -pkg_origin=codeforphilly -pkg_maintainer="Code for Philly " -pkg_scaffolding=emergence/scaffolding-site - -pkg_version() { - scaffolding_detect_pkg_version -} diff --git a/script/studio b/script/studio index 97749d52..ed36f8bc 100755 --- a/script/studio +++ b/script/studio @@ -9,8 +9,17 @@ cd "$(dirname "$0")/.." script/-studio-bootstrap +# clean up environment unset DEBUG -[ -n "${1}" ] && cd "${1}" + + +# switch to alternative target directory if desired +if [ -n "${1}" ]; then + echo + echo "==> studio: changing into directory ${1}" + echo " Be sure to manually source .studiorc under the desired primary workspace" + cd "${1}" +fi echo @@ -42,22 +51,22 @@ if [ "$(docker ps -aq -f name="${STUDIO_NAME}")" ]; then echo docker attach "${STUDIO_NAME}" launch_studio=false - ;; + break;; s|S) echo "==> studio: stopping existing container…" docker stop "${STUDIO_NAME}" > /dev/null - ;; + break;; n|N) echo "==> studio: doing nothing with existing container… an error is likely to occur" - ;; + break ;; *) - echo "==> studio: $choice is invalid" - ;; + echo "==> studio: $choice is invalid";; esac done fi if [ $launch_studio = true ]; then + export HAB_DOCKER_STUDIO_IMAGE="ghcr.io/emergenceplatform/studio:latest" echo echo "==> studio: launching Docker-powered Chef Habitat studio…" set +e