Skip to content

Commit

Permalink
chore: adds org selecting
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Aug 30, 2024
1 parent 79ee116 commit 05bb152
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions blueprint.cue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ci: {
provider: "aws"
path: "global/ci/earthly"
}
org: "Catalyst"
satellite: "ci"
}
}
Expand Down
4 changes: 4 additions & 0 deletions blueprint/schema/_embed/schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions blueprint/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 4 additions & 0 deletions blueprint/schema/schema_go_gen.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 14 additions & 3 deletions forge/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -108,14 +113,20 @@ runs:
fi
fi
echo "org=$ORG" >> $GITHUB_OUTPUT
echo "::add-mask::$TOKEN"
echo "token=$TOKEN" >> $GITHUB_OUTPUT
- name: Login to Earthly Cloud
if: steps.earthly.outputs.token != ''
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: |
Expand Down

0 comments on commit 05bb152

Please sign in to comment.