Skip to content

Commit 3cee83a

Browse files
authored
Add release workflow for GitHub actions (#2)
1 parent 6ac5b81 commit 3cee83a

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

.github/actions/cf-github-deploy/action.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ inputs:
55
app-name:
66
description: "Base name of the deployed CAP app"
77
required: true
8+
environment:
9+
description: "Deployment environment name"
10+
required: true
811

912
runs:
1013
using: "composite"
@@ -21,18 +24,20 @@ runs:
2124
uses: actions/github-script@v7
2225
env:
2326
URL: ${{ steps.get-url.outputs.url }}
27+
ENVIRONMENT: ${{ inputs.environment }}
2428
with:
2529
script: |
2630
const { owner, repo } = context.repo
2731
const ref = context.ref
2832
const url = process.env.URL
33+
const environment = process.env.ENVIRONMENT
2934
3035
const deployment = await github.rest.repos.createDeployment({
3136
owner,
3237
repo,
3338
ref,
3439
required_contexts: [],
35-
environment: 'Staging',
40+
environment,
3641
auto_merge: false,
3742
description: 'Deployed to Cloud Foundry',
3843
})

.github/workflows/cf.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@ name: Cloud Foundry
22

33
on:
44
workflow_call:
5+
inputs:
6+
cf-api:
7+
description: 'Cloud Foundry API endpoint'
8+
required: true
9+
type: string
10+
cf-org:
11+
description: 'Cloud Foundry organization'
12+
required: true
13+
type: string
14+
cf-space:
15+
description: 'Cloud Foundry space'
16+
required: true
17+
type: string
18+
environment:
19+
description: 'Deployment environment name'
20+
required: true
21+
type: string
22+
523
workflow_dispatch:
624
merge_group:
725
push:
@@ -27,9 +45,9 @@ jobs:
2745
node-version: 22
2846
- uses: ./.github/actions/cf-setup
2947
with:
30-
cf-api: ${{ vars.CF_API }}
31-
cf-org: ${{ vars.CF_ORG }}
32-
cf-space: ${{ vars.CF_SPACE }}
48+
cf-api: ${{ inputs.cf-api || vars.CF_API }}
49+
cf-org: ${{ inputs.cf-org || vars.CF_ORG }}
50+
cf-space: ${{ inputs.cf-space || vars.CF_SPACE }}
3351
cf-username: ${{ vars.CF_USERNAME }}
3452
cf-password: ${{ secrets.CF_PASSWORD }}
3553
- run: npm clean-install
@@ -38,6 +56,7 @@ jobs:
3856
- uses: ./.github/actions/cf-github-deploy
3957
with:
4058
app-name: ${{ env.APP_NAME }}
59+
environment: ${{ inputs.environment || 'Staging' }}
4160

4261
- run: cf logs ${{ env.APP_NAME }} --recent
4362
- run: cf logs orders-srv --recent

.github/workflows/release.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
tests:
10+
uses: cap-sandbox/samples/.github/workflows/test.yaml@main
11+
secrets: inherit
12+
13+
deploy-cf:
14+
needs: [tests]
15+
uses: cap-sandbox/samples/.github/workflows/cf.yaml@main
16+
secrets: inherit
17+
with:
18+
cf-api: ${{ vars.CF_API_PRODUCTION }}
19+
cf-org: ${{ vars.CF_ORG_PRODUCTION }}
20+
cf-space: ${{ vars.CF_SPACE_PRODUCTION }}
21+
environment: Production

0 commit comments

Comments
 (0)