Skip to content

Commit

Permalink
fix: run push on separate workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic committed Dec 2, 2024
1 parent 451cc79 commit baf7ada
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Build

on:
pull_request: {}
push:
branches:
- main
workflow_dispatch:
inputs:
channel:
Expand All @@ -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
Expand All @@ -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 }}"
47 changes: 47 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit baf7ada

Please sign in to comment.