From baf7ada602ae7bec306c929ec5d065d4ecdf6d63 Mon Sep 17 00:00:00 2001 From: Duologic Date: Mon, 2 Dec 2024 13:45:23 +0100 Subject: [PATCH] fix: run push on separate workflow --- .github/workflows/build.yaml | 24 ++++++------------ .github/workflows/push.yaml | 47 ++++++++++++++++++++++++++++++++++++ Makefile | 2 +- 3 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/push.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e830098..d385c60 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,9 +2,6 @@ name: Build on: pull_request: {} - push: - branches: - - main workflow_dispatch: inputs: channel: @@ -16,9 +13,6 @@ on: required: true default: current -env: - UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} - jobs: build: runs-on: ubuntu-22.04 @@ -38,16 +32,12 @@ jobs: env: CROSSPLANE: './crossplane' - - name: Login to Upbound - uses: docker/login-action@v3 - if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != '' - with: - registry: xpkg.upbound.io - username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} - password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} + - name: Check if file changed + id: changed + uses: tj-actions/verify-changed-files@v20 - - name: Push xpkg - run: make push - if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != '' + - name: No files changed + if: "${{ steps.changed.outputs.files_changed == 'true' }}" + run: "echo 'Please run `make build`' && exit 1" env: - CROSSPLANE: './crossplane' + CHANGED_FILES: "${{ steps.changed.outputs.changed_files }}" diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 0000000..8c236a6 --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,47 @@ +name: Build + +on: + push: + tags: + - '*' + workflow_dispatch: + inputs: + channel: + description: release channel + required: true + default: stable + version: + description: release version + required: true + default: current + +env: + UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: setup Crossplane cli + uses: crossplane-contrib/xpkg-action@master + with: + channel: ${{ github.event.inputs.channel }} + version: ${{ github.event.inputs.version }} + command: -h + + - name: Login to Upbound + uses: docker/login-action@v3 + if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != '' + with: + registry: xpkg.upbound.io + username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} + password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} + + - name: Push xpkg + run: make push + if: ${{ github.ref == 'refs/heads/main' }} && env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != '' + env: + CROSSPLANE: './crossplane' diff --git a/Makefile b/Makefile index 8572d8f..2f4d226 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ packages=$(wildcard packages/*) push_packages: packages $(packages) rm -rf output && mkdir -p output/ $(foreach pkg,$(packages),$(CROSSPLANE) xpkg build --package-root=$(pkg) --package-file=output/$(patsubst packages/%,%,$(pkg)).xpkg;) - $(foreach pkg,$(packages),echo $(CROSSPLANE) xpkg push configuration -f output/$(patsubst packages/%,%,$(pkg)).xpkg registry.upbound.io/grafana/$(patsubst packages/%,%,$(pkg)).xpkg:v$(LIBRARY_VERSION)-$(PROVIDER_VERSION);) + $(foreach pkg,$(packages),$(CROSSPLANE) xpkg push configuration -f output/$(patsubst packages/%,%,$(pkg)).xpkg registry.upbound.io/grafana/$(patsubst packages/%,%,$(pkg)).xpkg:v$(LIBRARY_VERSION)-$(PROVIDER_VERSION);) docs: $(shell find grafanaplane/ -type f) @rm -rf docs/