Commit 3d26a727 authored by Thomas Boni's avatar Thomas Boni
Browse files

update job as described in !148#note_509845560

parent 54d59e21
Loading
Loading
Loading
Loading
+10 −20
Original line number Diff line number Diff line
@@ -11,13 +11,13 @@ It exposes `node_modules` as cache to other jobs of your pipeline. It allows you
   [`package.json`](https://docs.npmjs.com/cli/v6/configuring-npm/package-json){:target="_blank"}
   file which contains the requirements
1. Ensure that your project have
  [`gulpfile.js`](https://gulpjs.com/docs/en/getting-started/javascript-and-gulpfiles/#gulpfile-explained){:target="_blank"} or [`gulpfile.ts`](https://gulpjs.com/docs/en/getting-started/javascript-and-gulpfiles/#transpilation){:target="_blank"} file which contains your tasks
   [`gulpfile.js`](https://gulpjs.com/docs/en/getting-started/javascript-and-gulpfiles/#gulpfile-explained){:target="_blank"}
   or
   [`gulpfile.ts`](https://gulpjs.com/docs/en/getting-started/javascript-and-gulpfiles/#transpilation){:target="_blank"}
   file which contains your tasks
1. Add the corresponding URL to your `.gitlab-ci.yml` file (see [Getting
   started](/use-the-hub)). Example:
    ```yaml
    include:
      - remote: 'https://jobs.r2devops.io/gulp.yml'
    ```
   started](/use-the-hub)). Example: ```yaml include:
      - remote: 'https://jobs.r2devops.io/gulp.yml' ```
1. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
customization](/use-the-hub/#jobs-customization)
1. Well done, your job is ready to work ! 😀
@@ -44,16 +44,6 @@ It exposes `node_modules` as cache to other jobs of your pipeline. It allows you
| `INSTALL_OPTIONS` | Additional options for the installation of `PACKAGE_MANAGER` <br/> *Ex: For npm `--save-dev`*  | ` ` |
| `GULPFILE_PATH` | Path (from `PROJECT_ROOT`) to your  gulpfile `gulpfile.js` or `gulpfile.ts`| ` ` |
| `GULP_TASKS` | List of your tasks to run with `gulp` (separated by ; ). <br/> *Ex: "minify-css; minify-js;"* | ` ` |


### Cache

This job creates a global cache configuration. Regarding the configuration
applied, cache behavior is the following:

* Shared between all jobs and pipelines on the same branch
* Contains folder `$PROJECT_ROOT/node_modules`
* If `npm install` or `yarn install` produces different result than the cached content

More information on Gitlab caching mechanism in [Gitlab CI/CD caching
documentation](https://docs.gitlab.com/ee/ci/caching/index.html).
| `GULP_OUTPUT_FOLDER` | If needed, path to the output produced by your scripts (path relative from the `PROJECT_ROOT`) | `build` |
| `PAGES_DEPLOY` | If enabled, prepare your build result to be deployed on pages (require [pages job](jobs/deploy/pages/)) | `false` |
| `PAGES_FOLDER` | Path where to copy the output to be exposed for deployment on [pages](jobs/deploy/pages/) (path relative from the root of the repository) | `./website_build` |
+26 −36
Original line number Diff line number Diff line
#Job from R2Devops hub --> r2devops.io

stages:
  - others

cache:
  key:
    files:
      - "${PROJECT_ROOT}/package.json"
    prefix: "$PACKAGE_MANAGER-${CI_COMMIT_REF_SLUG}"
  paths:
    - "${PROJECT_ROOT}/node_modules"
  when: "on_success"

gulp:
  stage: others
  image:
    name: node:15.7-buster
    entrypoint: [""]
  stage: others
  variables:
    PROJECT_ROOT: "."
    PACKAGE_MANAGER: "npm"
    INSTALL_OPTIONS: ""
    GULPFILE_PATH: "."
    GULP_TASKS: ""
    OUTPUT_FOLDER: "./build/"

    # Deploy on GitLab pages
    GITLAB_PAGES_DEPLOY: "true"
    GITLAB_PAGES_OUTPUT: "./website_build"

    GULP_OUTPUT_FOLDER: "./build/"
    # Deploy on pages
    PAGES_DEPLOY: "false"
    PAGES_FOLDER: "./website_build"

  script:
    # Working directory
@@ -53,16 +43,16 @@ gulp:
    -   gulp -f "$GULPFILE_PATH" "$TASK"
    - done

    # To deploy on GitLab pages
    - if [ "$GITLAB_PAGES_DEPLOY" == "true" ]; then
    - mkdir $GITLAB_PAGES_OUTPUT
    - cp -Rp $OUTPUT_FOLDER $GITLAB_PAGES_OUTPUT
    # To deploy on pages
    - if [ "$PAGES_DEPLOY" == "true" ]; then
        # Pages folder must to be at the root of the repo
    -   cd $CI_PROJECT_DIR
    -   cp -r ${PROJECT_ROOT}/${GULP_OUTPUT_FOLDER} ${CI_PROJECT_DIR}/${PAGES_FOLDER}
    - fi

  artifacts:
    when: always
    expose_as: "gulp artefact"
    expose_as: "gulp artifact"
    paths:
    - "$OUTPUT_FOLDER"
    # To deploy on GitLab pages
    - "$GITLAB_PAGES_OUTPUT"
      - "${PROJECT_ROOT}/${GULP_OUTPUT_FOLDER}"
      # To deploy on pages
      - "${PAGES_FOLDER}"
+0 −1
Original line number Diff line number Diff line
@@ -6,5 +6,4 @@ maintainer: coconux
license: MIT
labels:
  - GitLab
  - Optimization
  - Utilities