From 05bb15203b66a27db86bf0a498cc9fabf629735a Mon Sep 17 00:00:00 2001 From: Joshua Gilman Date: Fri, 30 Aug 2024 13:24:59 -0400 Subject: [PATCH] chore: adds org selecting --- blueprint.cue | 1 + blueprint/schema/_embed/schema.cue | 4 ++++ blueprint/schema/schema.go | 4 ++++ blueprint/schema/schema_go_gen.cue | 4 ++++ forge/actions/setup/action.yml | 17 ++++++++++++++--- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/blueprint.cue b/blueprint.cue index 88a1be1c..799812b1 100644 --- a/blueprint.cue +++ b/blueprint.cue @@ -16,6 +16,7 @@ ci: { provider: "aws" path: "global/ci/earthly" } + org: "Catalyst" satellite: "ci" } } diff --git a/blueprint/schema/_embed/schema.cue b/blueprint/schema/_embed/schema.cue index cb86cb31..16984f1d 100644 --- a/blueprint/schema/_embed/schema.cue +++ b/blueprint/schema/_embed/schema.cue @@ -69,6 +69,10 @@ package schema // +optional credentials?: #Secret @go(Credentials) + // Org specifies the Earthly Cloud organization to use. + // +optional + org?: null | string @go(Org,*string) + // Satellite contains the satellite to use for caching. // +optional satellite?: null | string @go(Satellite,*string) diff --git a/blueprint/schema/schema.go b/blueprint/schema/schema.go index ec4bf9bb..0ab4c38e 100644 --- a/blueprint/schema/schema.go +++ b/blueprint/schema/schema.go @@ -75,6 +75,10 @@ type ProviderEarthly struct { // +optional Credentials Secret `json:"credentials"` + // Org specifies the Earthly Cloud organization to use. + // +optional + Org *string `json:"org"` + // Satellite contains the satellite to use for caching. // +optional Satellite *string `json:"satellite"` diff --git a/blueprint/schema/schema_go_gen.cue b/blueprint/schema/schema_go_gen.cue index 48631839..4c19d9b9 100644 --- a/blueprint/schema/schema_go_gen.cue +++ b/blueprint/schema/schema_go_gen.cue @@ -69,6 +69,10 @@ package schema // +optional credentials?: #Secret @go(Credentials) + // Org specifies the Earthly Cloud organization to use. + // +optional + org?: null | string @go(Org,*string) + // Satellite contains the satellite to use for caching. // +optional satellite?: null | string @go(Satellite,*string) diff --git a/forge/actions/setup/action.yml b/forge/actions/setup/action.yml index 0b3b20b2..46ddff71 100644 --- a/forge/actions/setup/action.yml +++ b/forge/actions/setup/action.yml @@ -23,7 +23,7 @@ runs: uses: actions/cache@v4 with: path: /usr/local/bin/forge - key: ${{ runner.os }}-forge-${{ hashFiles('forge/cli/**') }} + key: ${{ runner.os }}-forge-${{ hashFiles('forge/cli/**', 'blueprint/**') }} restore-keys: | ${{ runner.os }}-forge- - name: Build Forge CLI @@ -97,8 +97,13 @@ runs: run: | BP=$(forge blueprint dump .) - EARTHLY=$(echo "$BP" | jq -r .ci.providers.earthly.credentials) + EARTHLY=$(echo "$BP" | jq -r .ci.providers.earthly) if [[ "$EARTHLY" != "null" ]]; then + ORG=$(echo "$BP" | jq -r .ci.providers.earthly.org) + fi + + EARTHLY_CREDS=$(echo "$BP" | jq -r .ci.providers.earthly.credentials) + if [[ "$EARTHLY_CREDS" != "null" ]]; then SECRET=$(forge secret get -b . ci.providers.earthly.credentials) TOKEN=$(echo "$SECRET" | jq -r .token) @@ -108,6 +113,8 @@ runs: fi fi + echo "org=$ORG" >> $GITHUB_OUTPUT + echo "::add-mask::$TOKEN" echo "token=$TOKEN" >> $GITHUB_OUTPUT - name: Login to Earthly Cloud @@ -115,7 +122,11 @@ runs: shell: bash run: | earthly account login --token "${{ steps.earthly.outputs.token }}" - + - name: Set Earthly organization + if: steps.earthly.outputs.org != '' + shell: bash + run: | + earthly org select "${{ steps.earthly.outputs.org }}"" - name: Testing shell: bash run: |