ããä½ï¼
GitLab CIä¸ã§è¡ã£ãå¤æ´ãMerge Requestã¨ãã¦æããããã®ãã¼ã«ã§ããï¼éçºæéã¯1é±éãããï¼
GitHub Actionsã 㨠peter-evans/create-pull-request ã便å©ã§ãã使ã£ã¦ããã®ã§ãããåããããªãã¨ãGitLab CIã§ãããããã¦ä½ãã¾ããã
ãµã³ãã«
ä¸çªç°¡åãªãµã³ãã«ã¯ããã
stages: - build create_mr_for_changes: stage: build image: debian:stable-slim before_script: # Download and install latest create-merge-request - apt-get update - apt-get install -y curl - VERSION=$(curl -s --fail https://gitlab.com/sue445/create-merge-request/-/raw/main/VERSION?ref_type=heads) - pushd /tmp - curl --retry 3 -L -o create-merge-request.tar.gz https://gitlab.com/sue445/create-merge-request/-/releases/${VERSION}/downloads/create-merge-request_Linux_x86_64.tar.gz - tar xzvf create-merge-request.tar.gz - mv create-merge-request /usr/local/bin - popd script: # TODO: Add your changes - date > now.txt # Create Merge Request if repo is changed - create-merge-request rules: # Run only scheduled pipeline # ref. https://docs.gitlab.com/ee/ci/pipelines/schedules.html - if: $CI_PIPELINE_SOURCE == "schedule"
ãã®ãµã³ãã«ã§ã¯å®è¡æã«now.txtãæ´æ°ãã¦ããã®å·®åãMerge Requestã¨ãã¦æãã¦ãã¾ãã
é å¼µããã¤ã³ã
gitã³ãã³ãã使ããã«gitãªãã¸ããªã«ã¢ã¯ã»ã¹ãã
create-merge-requestã¯Goã§ä½ãã¹ã¿ã³ãã¢ãã¼ã³ãã¤ããªã¨ãã¦é å¸ãã¦ãã¾ãã
ãããã¹ã¿ã³ãã¢ãã¼ã³ãã¤ããªã¨ãã¦é å¸ãã¦ãããã¼ã«ãå®è¡ç°å¢ã«ã¤ã³ã¹ãã¼ã«ããã¦ããgitã³ãã³ãã«ä¾åãã¦ããã¨çã®ã¹ã¿ã³ãã¢ãã¼ã³ã¨ã¯ãããªãããã https://github.com/go-git/go-git ã¨ããGoå®è£ ã®gitãå©ç¨ãã¦å®è¡ç°å¢ã«gitãã¤ã³ã¹ãã¼ã«ããã¦ããªãã¦ã使ããããã«ãã¾ãããï¼ã·ã¹ãã ã«ã¤ã³ã¹ãã¼ã«ããã¦ããgitã³ãã³ãã使ãã¨gitã®ãã¼ã¸ã§ã³ãå¤ãã£ãæã«æ¯ãèããå¤ããã¨é¢åãªã®ã§å é¨ã«çµã¿è¾¼ãã æ¹ãä¾åã管çããããã¨ããå¬ãããããï¼
å¯è½ãªéããã©ã¡ã¼ã¿ãçç¥ã§ããããã«ãã
ä¸è¨ã®helpãè¦ã¦ããããã°åããã¾ãããGitLabã®ãªãã¸ããªã«æ°ããcommitãpushãã¦Merge Requestãæããã ãã§ãä¸è¨ã®ãã©ã¡ã¼ã¿ãç»å ´ãã¾ãã
REQUIRED PARAMETERS: --gitlab-api-endpoint value GitLab API Endpoint (e.g. https://gitlab.com/api/v4) [$GITLAB_API_ENDPOINT, $CI_API_V4_URL] --gitlab-access-token value GitLab access token [$GITLAB_ACCESS_TOKEN] --gitlab-project value GitLab Project Path (e.g. gitlab-org/gitlab) [$GITLAB_PROJECT, $CI_PROJECT_PATH] OPTIONAL PARAMETERS: --author-email value author email for commit (default: [email protected]) --author-name value author name for commit (default: create-merge-request) --commit-message value, -m value commit message (default: [create-merge-request] automated change) --source-branch value Merge Request branch name (default: create-merge-request/patch) --source-branch-suffix value Merge Request branch name suffix (none,random,timestamp,short-commit-hash) (default: none) --target-branch value Send Merge Request to this branch (e.g. main, master) (default: main) [$CI_DEFAULT_BRANCH] --title value, -t value Merge Request title (default: Changes by create-merge-request) --description value Merge Request description (default: Automated changes by [create-merge-request](https://gitlab.com/sue445/create-merge-request)) --labels value [ --labels value ] Merge Request labels --assignees value [ --assignees value ] Merge Request assignees (e.g. user1,user2) --reviewers value [ --reviewers value ] Merge Request reviewers (e.g. user1,user2)
ãããåæã§å¤§éã«ãã©ã¡ã¼ã¿ãè¨å®ãããã®ã¯å¤§å¤ã§ãã
GitLab CIã§ã¯ $CI_API_V4_URL
ã $CI_PROJECT_PATH
ãªã©ã®ç°å¢å¤æ°ãèªåã§ç¨æããã¦ãããããå¯è½ãªéããããããè¨å®ãèªã¿è¾¼ãããã«ãã¾ããã
ããã«ããGitLab CIã§å®è¡ããæã«ã¯ GITLAB_ACCESS_TOKEN
ã§GitLabã®ã¢ã¯ã»ã¹ãã¼ã¯ã³ã ãè¨å®ããã¦ããã°ã¨ããããMerge Requestãä½æã§ããããã«ãã¾ããã
ãã¾ã
Goã®ãã¤ããªãGitLabã®ãªãã¸ããªã®releasesã«æ·»ä»ããæã« https://github.com/goreleaser/goreleaser ãå©ç¨ããã®ã§ãããGitLab CIç¨ã®è¨å®ãç¾å¨ã®GitLabã§ã¯Deprecatedãªãã®ã ã£ãã®ã§ããããæãã¾ããã