Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample for "apply fixes" using GitLab CI #1373

Closed
jokay opened this issue Mar 31, 2022 · 3 comments
Closed

Sample for "apply fixes" using GitLab CI #1373

jokay opened this issue Mar 31, 2022 · 3 comments
Labels
O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity question Further information is requested

Comments

@jokay
Copy link
Contributor

jokay commented Mar 31, 2022

Is there any sample (.gitlab-ci.yml) for using apply fixes on a self-hosted GitLab?

megalinter:
  image: megalinter/megalinter-documentation:v5.10.0
  script: ["true"]
  variables:
    APPLY_FIXES: "all"
    DEFAULT_WORKSPACE: ${CI_PROJECT_DIR}
    LINTER_RULES_PATH: .gitlab/linters
    VALIDATE_ALL_CODEBASE: "true"
  artifacts:
    paths:
      - report
    expire_in: 1 hour

APPLY_FIXES_EVENT and APPLY_FIXES_MODE are only valid for GitHub but not GitLab.

@jokay jokay added the question Further information is requested label Mar 31, 2022
@nvuillam
Copy link
Member

There is not yet, but I have ideas about how to do that:

# MegaLinter GitLab CI job configuration file
# More info at https://megalinter.github.io

mega-linter:
  stage: test
  # You can override MegaLinter flavor used to have faster performances
  # More info at https://megalinter.github.io/flavors/
  image: megalinter/megalinter:v5
  before_script:
  - git config --global user.name "${GITLAB_USER_NAME}"
  - git config --global user.email "${GITLAB_USER_EMAIL}"
  script: 
    - "/bin/bash /entrypoint.sh"
    - git status
    - git add --all
    - git commit -m "[MegaLinter] Apply linters fixes [skip ci]" || echo "No changes to commit"
    - git push -o ci-skip http://root:$GITLAB_ACCESS_TOKEN_MEGALINTER @$CI_SERVER_HOST/$CI_PROJECT_PATH.git HEAD:$CI_COMMIT_REF_NAME
  variables:
    # All available variables are described in documentation
    # https://megalinter.github.io/configuration/
    DEFAULT_WORKSPACE: $CI_PROJECT_DIR
    # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
  artifacts:
    when: always
    paths:
      - report
    expire_in: 1 week

Meanwhile, you can manually copy-paste content of folder updated_sources available in artifacts

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2022

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label May 1, 2022
@jokay
Copy link
Contributor Author

jokay commented May 1, 2022

Couldn't get it to work, may be we see a native integration for GitLab one day which does not need any manual scripts.

Issue closed for now.

@jokay jokay closed this as completed May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants