Verified Commit 68f1c4a0 authored by Jamie Maynard's avatar Jamie Maynard
Browse files

Bring in handbook Pipeline

parent 1b164001
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+175 −0
Original line number Diff line number Diff line
# NOTE: Static Sites often want to optimize for fast build and deploy
#       pipeline times, so changes are published as quickly as possible.
#       Therefore, this default config includes optional variables, settings,
#       and caching, which help minimize job run times. For example,
#       disabling support for git LFS and submodules. There are also retry
#       and reliability settings which help prevent false build failures
#       due to occasional infrastructure availability problems. These are
#       all documented inline below, and can be changed or removed as
#       necessary, depending on the requirements for your repo or project.

###################################
#
# GENERAL/DEFAULT CONFIG:
#
###################################

stages:
  - prepare
  - deploy
  - test
  - notify
  - cleanup

include:
  - template: Security/Secret-Detection.gitlab-ci.yml

default:
  interruptible: true # All jobs are interruptible by default
  # The following 'retry' configuration settings may help avoid false build failures
  #  during brief problems with CI/CD infrastructure availability
  retry:
    max: 2 # This is confusing but this means "3 runs at max".
    when:
      - unknown_failure
      - api_failure
      - runner_system_failure
      - job_execution_timeout
      - stuck_or_timeout_failure

variables:
  # NOTE: The following PERFORMANCE and RELIABILITY variables are optional, but may
  #       improve performance of larger repositories, or improve reliability during
  #       brief problems with CI/CD infrastructure availability

  ### PERFORMANCE ###
  # GIT_* variables to speed up repo cloning/fetching
  GIT_DEPTH: 0
  # Disabling LFS and submodules will speed up jobs, because runners don't have to perform
  # the submodule steps during repo clone/fetch. These settings can be deleted if you are using
  # LFS or submodules.
  GIT_LFS_SKIP_SMUDGE: 1
  GIT_SUBMODULE_STRATEGY: none

  ### RELIABILITY ###
  # Reduce potential of flaky builds via https://docs.gitlab.com/ee/ci/yaml/#job-stages-attempts variables
  GET_SOURCES_ATTEMPTS: 3
  ARTIFACT_DOWNLOAD_ATTEMPTS: 3
  RESTORE_CACHE_ATTEMPTS: 3
  EXECUTOR_JOB_SECTION_ATTEMPTS: 3

.security-scanning: &security-scanning-rules
    if: '$CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'

.hugo:
  image: registry.gitlab.com/pages/hugo/hugo_extended:0.115.3
  stage: deploy
  needs: []
  script:
    - apk update
    - apk upgrade
    - apk add go npm yq curl coreutils
    - npm ci
    - hugo --enableGitInfo
  rules:
    - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
  artifacts:
    paths:
      - public

###################################
#
# DEPLOY STAGE
#
###################################

pages-review:
  extends: [.hugo]
  rules:
    - if: $CI_MERGE_REQUEST_IID
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    # There is no predefined CI variable that is formatted quite right
    # neither $CI_PAGES_URL nor $CI_JOB_URL have /-/ directly after the hostname
    url: https://gitlab-com.gitlab.io/-/content-sites/handbook/-/jobs/$CI_JOB_ID/artifacts/public/index.html
    on_stop: stop-pages-review
  variables:
    HUGO_ENVIRONMENT: review
    RUN_TYPE: MR

stop-pages-review:
  image: busybox
  stage: cleanup
  script:
    - echo "stop review app"
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    action: stop
  rules:
    - if: $CI_MERGE_REQUEST_IID
      when: manual
      allow_failure: true
  variables:
    GIT_STRATEGY: none

pages:
  extends: [.hugo]
  rules:
    # Only run the deploy on the default branch. If you want to deploy from Merge Request branches,
    # you can use Review Apps: https://docs.gitlab.com/ee/ci/review_apps
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: '$CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_DEPLOY == "true"'

####################################
##
## TEST STAGE
##
####################################

markdownlint:
  image:
    name: davidanson/markdownlint-cli2:0.4.0
    entrypoint: ["/bin/sh", "-c"]
  stage: test
  needs: []
  before_script:
    - npm install markdownlint-cli2-formatter-codequality markdownlint-cli2-formatter-pretty
  script:
    - ./scripts/lint-custom.sh
    - markdownlint-cli2 "content/**/*.md"
  rules:
    - <<: *security-scanning-rules
  artifacts:
    when: always
    expire_in: 1 month
    paths:
      - markdownlint-cli2-codequality.json
    reports:
      codequality: markdownlint-cli2-codequality.json

####################################
##
## NOTIFY STAGE
##
####################################

post_comment_on_failure:
  needs: ["markdownlint"]
  when: on_failure
  stage: notify
  image:
    name: gitlab/glab
    entrypoint: ["/bin/sh", "-c"]
  script:
    - apk add yq
    - glab auth login -t $MR_UPDATE_TOKEN
    - glab mr note $CI_MERGE_REQUEST_IID -m "$(./scripts/parse-codequality-report.sh -r ./markdownlint-cli2-codequality.json)"
  rules:
  - <<: *security-scanning-rules

secret_detection:
  needs: []
  dependencies: [] # Don't download artifacts, especially `./public/`
  rules:
    - <<: *security-scanning-rules
+5 −4
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ This document is maintained by the [Content Sites] Team.
### Heading h3

#### Heading h4

{{< /card >}}

{{% card header="**Output**" %}}
@@ -481,7 +482,7 @@ on how to use Mermaid. We have a number of Handbook-specific example in the

You can use [PlantUML](http://plantuml.com/) in Markdown blocks. For
example:

<!-- markdownlint-disable MD031 -->
{{< cardpane >}}
{{< card code=true  header="**Markdown**" lang="go-html-template" >}}
```plantuml
@@ -524,7 +525,7 @@ java ..> rocket

{{% /card %}}
{{< /cardpane >}}

<!-- markdownlint-enable MD031 -->
----

## Videos
@@ -766,7 +767,7 @@ a markdown document. The additional syntax highlighting makes the code easier t
function [supports a large number of languages](https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages)
including Ruby, Python, Rust, Swift, etc.

<!-- markdownlint-disable MD040 -->
<!-- markdownlint-disable MD040 MD031 -->
{{< cardpane >}}
{{< card code=true  header="**Markdown**" lang="mkd" >}}```ruby
def hello
@@ -806,7 +807,7 @@ end
```
{{% /card %}}
{{< /cardpane >}}
<!-- markdownlint-enable MD040 -->
<!-- markdownlint-enable MD040 MD031 -->
### Indented

It is also possible to get a code block to render by putting 4 space in front of the code you want to render as a code

package-lock.json

0 → 100644
+1616 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading