diff --git a/.github/workflows/preview.yaml b/.github/workflows/build-publish-ephemeral.yaml similarity index 78% rename from .github/workflows/preview.yaml rename to .github/workflows/build-publish-ephemeral.yaml index 5c409d82e..3bd31fdb2 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/build-publish-ephemeral.yaml @@ -1,4 +1,4 @@ -name: pull-requests-preview-deployment +name: Manage Pull Request Preview Instances on: pull_request: @@ -11,13 +11,16 @@ on: concurrency: preview-${{ github.ref }} jobs: - deploy-preview: - environment: pull-requests-preview + deploy-ephemeral-preview: + name: Deploy or Remove Ephemeral Preview + environment: + name: pull-requests-preview + url: 'https://${{ github.repository_owner }}.github.io${{ vars.DOCUSAURUS_BASE_URL }}pr-${{ github.event.pull_request.number }}' runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get Commit Hash id: commit_hash diff --git a/.github/workflows/build-publish-production.yaml b/.github/workflows/build-publish-production.yaml new file mode 100644 index 000000000..8ed6d3445 --- /dev/null +++ b/.github/workflows/build-publish-production.yaml @@ -0,0 +1,82 @@ +name: Build and Deploy Production Docker Images + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + +jobs: + build-stable: + name: Build Production Artifacts + environment: + name: stable + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup NodeJS + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + + - name: Install NodeJS Dependencies + run: npm install + + - name: Build Version Tag + id: build_version_tag + run: echo "IMAGE_SEMVER=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Build Container Image Metadata + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ${{ vars.REGISTRY }}/${{ vars.REGISTRY_ORG }}/${{ vars.IMG_NAME }} + # generate Docker tags based on the following events/attributes + tags: | + type=semver,pattern=v{{major}}.{{minor}}.{{patch}} + type=raw,value=latest + + + - name: Build App + env: + REACT_APP_VERSION: ${{ env.IMAGE_SEMVER }} + REACT_APP_DOCS_NEXT_HOST: ${{ vars.DOCS_NEXT_HOST }} + REACT_APP_DOCS_NEXT_ORG: ${{ vars.DOCS_NEXT_ORG }} + REACT_APP_DOCUSAURUS_BASE_URL: ${{ vars.DOCUSAURUS_BASE_URL }} + REACT_APP_TYPESENSE_PROTOCOL: ${{ vars.TYPESENSE_PROTOCOL }} + REACT_APP_TYPESENSE_HOST: ${{ vars.TYPESENSE_HOST }} + REACT_APP_TYPESENSE_PORT: ${{ vars.TYPESENSE_PORT }} + REACT_APP_TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_SEARCH_KEY }} + UMAMI_WEBSITE_ID: ${{ vars.UMAMI_WEBSITE_ID }} + UMAMI_ANALYTICS_DOMAIN: ${{ vars.UMAMI_ANALYTICS_DOMAIN }} + UMAMI_DATAHOST_URL: ${{ vars.UMAMI_DATAHOST_URL }} + UMAMI_DATA_DOMAIN: ${{ vars.UMAMI_DATA_DOMAINS }} + run: npm run build + + - name: Login to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Setup Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3.7.1 + + - name: Build and Push (Docker Image) + id: docker_build + uses: docker/build-push-action@v6.9.0 + with: + context: ./ + file: ./Dockerfile + provenance: false + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + annotations: ${{ steps.meta.outputs.annotations }} \ No newline at end of file diff --git a/.github/workflows/build-publish-staging.yaml b/.github/workflows/build-publish-staging.yaml new file mode 100644 index 000000000..32e4314ed --- /dev/null +++ b/.github/workflows/build-publish-staging.yaml @@ -0,0 +1,91 @@ +name: Build and Deploy Staging Docker Images + +on: + push: + branches: + - main + paths-ignore: + - '**/README.md' + - '**/CONTRIBUTING.md' + - '**/CONFIGURATION.md' + - '**/.devcontainer/**' + - "**/.github/workflows/**" + +jobs: + build-preview: + name: Build Staging Artifacts + environment: + name: preview + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup NodeJS + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + + - name: Install NodeJS Dependencies + run: npm install + + - name: Get Commit Hash + id: commit_hash + uses: prompt/actions-commit-hash@v3 + + - name: Get Current Date + id: date + run: echo "today=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT + + - name: Build Image Tag + id: build_image_tag + run: echo "image_version=${{ steps.date.outputs.today }}-${{github.run_number}}-${{ steps.commit_hash.outputs.short }}" >> $GITHUB_OUTPUT + + - name: Build Container Image Metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ vars.REGISTRY }}/${{ vars.REGISTRY_ORG }}/${{ vars.IMG_NAME }} + tags: | + type=raw,value=${{ steps.build_image_tag.outputs.image_version }} + + - name: Build App + env: + REACT_APP_VERSION: ${{ steps.build_image_tag.outputs.image_version }} + REACT_APP_DOCS_NEXT_HOST: ${{ vars.DOCS_NEXT_HOST }} + REACT_APP_DOCS_NEXT_ORG: ${{ vars.DOCS_NEXT_ORG }} + REACT_APP_DOCUSAURUS_BASE_URL: ${{ vars.DOCUSAURUS_BASE_URL }} + REACT_APP_TYPESENSE_PROTOCOL: ${{ vars.TYPESENSE_PROTOCOL }} + REACT_APP_TYPESENSE_HOST: ${{ vars.TYPESENSE_HOST }} + REACT_APP_TYPESENSE_PORT: ${{ vars.TYPESENSE_PORT }} + REACT_APP_TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_SEARCH_KEY }} + UMAMI_WEBSITE_ID: ${{ vars.UMAMI_WEBSITE_ID }} + UMAMI_ANALYTICS_DOMAIN: ${{ vars.UMAMI_ANALYTICS_DOMAIN }} + UMAMI_DATAHOST_URL: ${{ vars.UMAMI_DATAHOST_URL }} + UMAMI_DATA_DOMAIN: ${{ vars.UMAMI_DATA_DOMAINS }} + run: npm run build + + - name: Login to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Setup Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3.7.1 + + - name: Build and Push (Docker Image) + id: docker_build + uses: docker/build-push-action@v6.9.0 + with: + context: ./ + file: ./Dockerfile + provenance: false + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + annotations: ${{ steps.meta.outputs.annotations }} \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 353d8166e..000000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,184 +0,0 @@ -name: build-and-release - -on: - push: - branches: - - main - paths-ignore: - - '**/README.md' - - '**/CONTRIBUTING.md' - - '**/CONFIGURATION.md' - - '**/.devcontainer/devcontainer.json' - - '**/.devcontainer/.env' - - '**/.github/workflows/preview.yaml' - -jobs: - build-preview: - environment: preview - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup NodeJS - uses: actions/setup-node@v2 - with: - node-version: 18 # Use Node.js 18 here - - - name: Install Dependencies - run: npm install - - - name: Get Commit Hash - id: commit_hash - uses: prompt/actions-commit-hash@v3 - - - name: Build App - env: - REACT_APP_VERSION: ${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}-preview - REACT_APP_DOCS_NEXT_HOST: ${{ vars.DOCS_NEXT_HOST }} - REACT_APP_DOCS_NEXT_ORG: ${{ vars.DOCS_NEXT_ORG }} - REACT_APP_DOCUSAURUS_BASE_URL: ${{ vars.DOCUSAURUS_BASE_URL }} - REACT_APP_TYPESENSE_PROTOCOL: ${{ vars.TYPESENSE_PROTOCOL }} - REACT_APP_TYPESENSE_HOST: ${{ vars.TYPESENSE_HOST }} - REACT_APP_TYPESENSE_PORT: ${{ vars.TYPESENSE_PORT }} - REACT_APP_TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_SEARCH_KEY }} - UMAMI_WEBSITE_ID: ${{ vars.UMAMI_WEBSITE_ID }} - UMAMI_ANALYTICS_DOMAIN: ${{ vars.UMAMI_ANALYTICS_DOMAIN }} - UMAMI_DATAHOST_URL: ${{ vars.UMAMI_DATAHOST_URL }} - UMAMI_DATA_DOMAIN: ${{ vars.UMAMI_DATA_DOMAINS }} - run: npm run build - - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Setup Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - uses: docker/setup-buildx-action@v3 - - name: Build and Push (Docker Image) - id: docker_build - uses: docker/build-push-action@v2 - with: - context: ./ - file: ./Dockerfile - push: true - tags: | - ${{ vars.DOCKERHUB_REGISTRY }}/${{ vars.DOCKERHUB_USERNAME }}/${{ vars.IMG_NAME }}:${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}-preview - - build-stable: - environment: stable - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup NodeJS - uses: actions/setup-node@v2 - with: - node-version: 18 # Use Node.js 18 here - - - name: Install Dependencies - run: npm install - - - name: Get Commit Hash - id: commit_hash - uses: prompt/actions-commit-hash@v3 - - - name: Build App - env: - REACT_APP_VERSION: ${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}-stable - REACT_APP_DOCS_NEXT_HOST: ${{ vars.DOCS_NEXT_HOST }} - REACT_APP_DOCS_NEXT_ORG: ${{ vars.DOCS_NEXT_ORG }} - REACT_APP_DOCUSAURUS_BASE_URL: ${{ vars.DOCUSAURUS_BASE_URL }} - REACT_APP_TYPESENSE_PROTOCOL: ${{ vars.TYPESENSE_PROTOCOL }} - REACT_APP_TYPESENSE_HOST: ${{ vars.TYPESENSE_HOST }} - REACT_APP_TYPESENSE_PORT: ${{ vars.TYPESENSE_PORT }} - REACT_APP_TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_SEARCH_KEY }} - UMAMI_WEBSITE_ID: ${{ vars.UMAMI_WEBSITE_ID }} - UMAMI_ANALYTICS_DOMAIN: ${{ vars.UMAMI_ANALYTICS_DOMAIN }} - UMAMI_DATAHOST_URL: ${{ vars.UMAMI_DATAHOST_URL }} - UMAMI_DATA_DOMAIN: ${{ vars.UMAMI_DATA_DOMAINS }} - run: npm run build - - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Setup Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - uses: docker/setup-buildx-action@v3 - - name: Build and Push (Docker Image) - id: docker_build - uses: docker/build-push-action@v2 - with: - context: ./ - file: ./Dockerfile - push: true - tags: | - ${{ vars.DOCKERHUB_REGISTRY }}/${{ vars.DOCKERHUB_USERNAME }}/${{ vars.IMG_NAME }}:latest - ${{ vars.DOCKERHUB_REGISTRY }}/${{ vars.DOCKERHUB_USERNAME }}/${{ vars.IMG_NAME }}:${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}-stable - - # - name: Image Digest - # run: echo ${{ steps.docker_build.outputs.digest }} - - update-helm-charts: - needs: [build-preview, build-stable] - environment: preview - runs-on: ubuntu-latest - - steps: - - name: Get Commit Hash - id: commit_hash - uses: prompt/actions-commit-hash@v3 - - - name: Show Commit Hash Digest - run: echo ${{ steps.commit_hash.outputs.short }} - - - name: Configure Git User as GitHub Actions Bot - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - - - name: Checkout - uses: actions/checkout@v4 - with: - repository: "${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}" - token: ${{ secrets.DOCS_NEXT_CHARTS_TOKEN }} - - - name: Update Charts and Commit Changes - id: update_charts - env: - image: ${{ vars.DOCKERHUB_REGISTRY }}\/${{ vars.DOCKERHUB_USERNAME }}\/${{ vars.IMG_NAME }} - run: | - # docusaurus - sed -i 's/^version: .*/version: ${{ vars.APP_VERSION }}.${{github.run_number}}/' ./charts/docusaurus/Chart.yaml - sed -i 's/^appVersion: .*/appVersion: ${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}/' ./charts/docusaurus/Chart.yaml - sed -i 's/^tag: .*/tag: ${{ vars.APP_VERSION }}.${{github.run_number}}-${{ steps.commit_hash.outputs.short }}/' ./charts/docusaurus/values.yaml - sed -i 's/^image: .*/image: ${{ env.image }}/' ./charts/docusaurus/values.yaml - cat ./charts/docusaurus/Chart.yaml - echo "" - echo "---" - echo "" - cat ./charts/docusaurus/values.yaml - # commit and push - git commit -am "Automatic commit from GitHub Actions triggered by action #${{github.run_number}}" - git remote set-url origin https://${{ secrets.DOCS_NEXT_CHARTS_TOKEN }}@github.com/${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}.git - git push origin main - - - - - - \ No newline at end of file