From 66cb56de7967959f2aea5cfb6f4deaecb25c899f Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Tue, 11 Oct 2022 12:01:18 +0300 Subject: [PATCH] CI: Trigger tag on CI changes (#55388) * Trigger tag on CI changes * Use github token available for PRs Remove remote addition * Replace origin with full url Remove fetch for origin Fix fetch Remove --quite Add rebase Stash changes from verify-gen-cue Cleanup * Add --quiet when fetching --- .drone.yml | 87 +++++++++++++++--------------- scripts/drone/events/release.star | 3 -- scripts/drone/pipelines/build.star | 2 +- scripts/drone/steps/lib.star | 13 ++--- 4 files changed, 53 insertions(+), 52 deletions(-) diff --git a/.drone.yml b/.drone.yml index 570146027f6..c09915ef025 100644 --- a/.drone.yml +++ b/.drone.yml @@ -356,6 +356,38 @@ steps: - grabpl image: grafana/build-container:1.6.3 name: yarn-install +- commands: + - git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git" + --depth=1 + - cd grafana-enterprise + - git fetch origin "refs/tags/*:refs/tags/*" --quiet + - if git show-ref --tags $${TEST_TAG} --quiet; then git tag -d $${TEST_TAG} && git + push --delete origin $${TEST_TAG}; fi + - git tag $${TEST_TAG} && git push origin $${TEST_TAG} + - cd - + - git fetch https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git "refs/tags/*:refs/tags/*" + --quiet && git fetch --quiet + - if git show-ref --tags $${TEST_TAG} --quiet; then git tag -d $${TEST_TAG} && git + push --delete https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git $${TEST_TAG}; + fi + - git tag $${TEST_TAG} && git push https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git + $${TEST_TAG} + environment: + DOWNSTREAM_REPO: + from_secret: downstream + GITHUB_TOKEN: + from_secret: github_token_pr + TEST_TAG: v0.0.0-test + failure: ignore + image: grafana/build-container:1.6.3 + name: trigger-test-release + when: + paths: + include: + - .drone.yml + - pkg/build/** + repo: + - grafana/grafana - failure: ignore image: grafana/drone-downstream name: trigger-enterprise-downstream @@ -1188,19 +1220,23 @@ steps: - git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git" --depth=1 - cd grafana-enterprise - - git fetch origin "refs/tags/*:refs/tags/*" - - git tag -d $${TEST_TAG} && git push --delete origin $${TEST_TAG} && git tag $${TEST_TAG} - && git push origin $${TEST_TAG} + - git fetch origin "refs/tags/*:refs/tags/*" --quiet + - if git show-ref --tags $${TEST_TAG} --quiet; then git tag -d $${TEST_TAG} && git + push --delete origin $${TEST_TAG}; fi + - git tag $${TEST_TAG} && git push origin $${TEST_TAG} - cd - - - git fetch origin "refs/tags/*:refs/tags/*" - - git remote add downstream https://$${GITHUB_TOKEN}@github.com/grafana/$${DOWNSTREAM_REPO}.git - - git tag -d $${TEST_TAG} && git push --delete downstream --quiet $${TEST_TAG} && - git tag $${TEST_TAG} && git push downstream $${TEST_TAG} --quiet + - git fetch https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git "refs/tags/*:refs/tags/*" + --quiet && git fetch --quiet + - if git show-ref --tags $${TEST_TAG} --quiet; then git tag -d $${TEST_TAG} && git + push --delete https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git $${TEST_TAG}; + fi + - git tag $${TEST_TAG} && git push https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git + $${TEST_TAG} environment: DOWNSTREAM_REPO: from_secret: downstream GITHUB_TOKEN: - from_secret: github_token + from_secret: github_token_pr TEST_TAG: v0.0.0-test failure: ignore image: grafana/build-container:1.6.3 @@ -2204,9 +2240,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -2270,9 +2303,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -2339,9 +2369,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -2447,9 +2474,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -2520,9 +2544,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -2864,9 +2885,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -2957,9 +2975,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -3059,9 +3074,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -3161,9 +3173,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -3319,9 +3328,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -3412,9 +3418,6 @@ trigger: - promote ref: - refs/tags/v* - repo: - exclude: - - grafana/grafana type: docker volumes: - host: @@ -5629,6 +5632,6 @@ kind: secret name: packages_secret_access_key --- kind: signature -hmac: 694dd8dd441da98425a1d41750ecfa2a6946f2329de2f321be734b031f9cc2e3 +hmac: a8e4587efd7da775019ed2812c5980fb43fdb9ef5da50e2ac7e5c73151b6a685 ... diff --git a/scripts/drone/events/release.star b/scripts/drone/events/release.star index 837f96eaca2..01ed719ed02 100644 --- a/scripts/drone/events/release.star +++ b/scripts/drone/events/release.star @@ -445,9 +445,6 @@ def release_pipelines(ver_mode='release', trigger=None): ] }, 'ref': ['refs/tags/v*',], - 'repo': { - 'exclude': ['grafana/grafana'], - }, } # The release pipelines include also enterprise ones, so both editions are built for a release. diff --git a/scripts/drone/pipelines/build.star b/scripts/drone/pipelines/build.star index d0f3d3cda58..817350252c5 100644 --- a/scripts/drone/pipelines/build.star +++ b/scripts/drone/pipelines/build.star @@ -53,7 +53,7 @@ def build_e2e(trigger, ver_mode, edition): yarn_install_step(), ] build_steps = [] - if ver_mode == 'main': + if ver_mode == 'main' or ver_mode == 'pr': build_steps.extend([trigger_test_release()]) if ver_mode == 'pr': build_steps.extend([enterprise_downstream_step(edition=edition, ver_mode=ver_mode)]) diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 6c40bc329a1..a1f70c53e5d 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -1202,19 +1202,20 @@ def trigger_test_release(): 'name': 'trigger-test-release', 'image': build_image, 'environment': { - 'GITHUB_TOKEN': from_secret('github_token'), + 'GITHUB_TOKEN': from_secret('github_token_pr'), 'DOWNSTREAM_REPO': from_secret('downstream'), 'TEST_TAG': 'v0.0.0-test', }, 'commands': [ 'git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git" --depth=1', 'cd grafana-enterprise', - 'git fetch origin "refs/tags/*:refs/tags/*"', - 'git tag -d $${TEST_TAG} && git push --delete origin $${TEST_TAG} && git tag $${TEST_TAG} && git push origin $${TEST_TAG}', + 'git fetch origin "refs/tags/*:refs/tags/*" --quiet', + 'if git show-ref --tags $${TEST_TAG} --quiet; then git tag -d $${TEST_TAG} && git push --delete origin $${TEST_TAG}; fi', + 'git tag $${TEST_TAG} && git push origin $${TEST_TAG}', 'cd -', - 'git fetch origin "refs/tags/*:refs/tags/*"', - 'git remote add downstream https://$${GITHUB_TOKEN}@github.com/grafana/$${DOWNSTREAM_REPO}.git', - 'git tag -d $${TEST_TAG} && git push --delete downstream --quiet $${TEST_TAG} && git tag $${TEST_TAG} && git push downstream $${TEST_TAG} --quiet', + 'git fetch https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git "refs/tags/*:refs/tags/*" --quiet && git fetch --quiet', + 'if git show-ref --tags $${TEST_TAG} --quiet; then git tag -d $${TEST_TAG} && git push --delete https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git $${TEST_TAG}; fi', + 'git tag $${TEST_TAG} && git push https://$${GITHUB_TOKEN}@github.com/grafana/grafana.git $${TEST_TAG}', ], 'failure': 'ignore', 'when': {