我正在构建一个应用程序,它依赖于静态资源文件。我希望能够找到一种方法,在工作流程中的特定时间下载资源文件。
我已经看到了git-hooks,我也看到了GitLab运行者等等。我没有偏好,我只是想能够简单地创建下载资源文件的自动化。
发布于 2021-02-17 06:47:12
我的GitLab.cli最终看起来如下所示:
我只需要生成一个新的私钥和公钥来添加到repo和一些命令中,这些命令是我从代码注释中可以找到的一堆不同的资源中收集的。
#resources that I used
#https://forum.gitlab.com/t/is-it-possible-to-commit-artifacts-into-the-git/22218/7
#https://forum.gitlab.com/t/git-push-from-inside-a-gitlab-runner/30554/5
#https://marcosschroh.github.io/posts/autobumping-with-gitlab/
#https://docs.gitlab.com/ee/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor
#https://docs.gitlab.com/ee/ci/ssh_keys/
#https://docs.gitlab.com/ee/ci/ssh_keys/#verifying-the-ssh-host-keys
#https://forum.gitlab.com/t/how-to-skip-the-pipeline-from-job-gitlab/44947/2
#https://docs.gitlab.com/ee/ci/yaml/#skip-pipeline
build-job:
stage: build
before_script:
##
## Create the SSH directory and give it the right permissions
##
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
##
## Install ssh-agent if not already installed, it is required by Docker.
## (change apt-get to yum if you use an RPM-based image)
##
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
# - ssh-keyscan $GITLAB_URL >> ~/.ssh/known_hosts
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
##
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
# - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
# - echo "$SSH_PRIVATE_KEY" | ssh-add - > /dev/null
- git config --global user.name "$CI_USERNAME"
- git config --global user.email "$CI_EMAIL"
- echo "$SSH_PUBLIC_KEY" >> ~/.ssh/id_rsa.pub
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
# test out stuff from
# https://gitlab.com/gitlab-org/gitlab-foss/-/issues/18106#note_12209180
- echo "Hello, $GITLAB_USER_LOGIN!"
# for your information
- whoami
- printenv
- git config --global user.name "${CI_USERNAME}"
- git config --global user.email "${CI_EMAIL}"
- git remote -v
- git status
# make your changes
- touch test.txt
- git add .
- git status
- git remote -v
# - git checkout master
# - git merge ci_processing
- git commit -m "Compiled PDF from $CI_COMMIT_SHORT_SHA [skip ci]" || echo "No changes, nothing to commit!"
- git remote rm origin && git remote add origin git@gitlab.com:$CI_PROJECT_PATH.git
- git push origin HEAD:$CI_COMMIT_REF_NAME # Pushes to the same branch as the trigger
# push changes
# always return true so that the build does not fail if there are no changes
# - git push origin ci_processing:${CI_BUILD_REF_NAME} || true
# - git push origin ci_processing:${CI_COMMIT_REF_NAME}
# - git push origin ci_processing
# test-job1:
# stage: test
# script:
# - echo "This job tests something"
# test-job2:
# stage: test
# script:
# - echo "This job tests something, but takes more time than test-job1."
# - echo "After the echo commands complete, it runs the sleep command for 20 seconds"
# - echo "which simulates a test that runs 20 seconds longer than test-job1"
# - sleep 20
# deploy-prod:
# stage: deploy
# script:
# - echo "This job deploys something from the $CI_COMMIT_BRANCH branch."https://stackoverflow.com/questions/66177778
复制相似问题