Only deploy on merges to master

This commit is contained in:
Byron Lathi
2024-06-06 18:53:14 -07:00
parent 310c760daf
commit 4d0e47b909

View File

@@ -7,6 +7,8 @@ stages:
build: build:
stage: build stage: build
rules:
- when: always
artifacts: artifacts:
paths: paths:
- ./dist - ./dist
@@ -16,13 +18,17 @@ build:
test: test:
stage: test stage: test
rules:
- when: always
script: script:
- echo "Haha no tests yet" - echo "Haha no tests yet"
deploy: deploy:
stage: deploy stage: deploy
only: rules:
- master # only run on MRs to main
- merge_requests - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
# run on commits to main
- if: $CI_COMMIT_BRANCH == "main"
script: script:
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${PACKAGE_PROJECT_ID}/packages/pypi dist/* - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${PACKAGE_PROJECT_ID}/packages/pypi dist/*