Skip to content

Commit 9f00df1

Browse files
committed
cds add github-actions
1 parent 736964a commit 9f00df1

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

.github/workflows/cf.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Cloud Foundry
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
default: Staging
8+
type: string
9+
workflow_dispatch:
10+
push:
11+
branches:
12+
- main
13+
14+
permissions:
15+
contents: read
16+
deployments: write
17+
18+
concurrency:
19+
group: cf-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
20+
cancel-in-progress: true
21+
22+
env:
23+
APP_NAME: xtravels
24+
jobs:
25+
deploy:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v5
29+
- uses: actions/setup-node@v5
30+
with:
31+
node-version: 22
32+
- uses: actions/setup-java@v5
33+
with:
34+
distribution: sapmachine
35+
java-version: 21
36+
cache: maven
37+
- uses: cap-js/cf-setup@v1
38+
with:
39+
cf-api: ${{ vars.CF_API }}
40+
cf-org: ${{ vars.CF_ORG }}
41+
cf-space: ${{ vars.CF_SPACE }}
42+
cf-username: ${{ vars.CF_USERNAME }}
43+
cf-password: ${{ secrets.CF_PASSWORD }}
44+
- run: npm install
45+
- run: npx cds up
46+
47+
- run: cf logs "${{ env.APP_NAME }}" --recent
48+
if: always()
49+
- run: cf logs "${{ env.APP_NAME }}-srv" --recent
50+
if: always()
51+
- run: cf logs "${{ env.APP_NAME }}-db-deployer" --recent
52+
if: always()
53+
54+
- name: Get application URL
55+
id: route
56+
shell: bash
57+
run: |
58+
host=$(cf app "${APP_NAME}" | awk '/routes:/ {print $2}' | sed -E 's#^https?://##; s/,.*$//')
59+
echo "url=https://$host" >> "$GITHUB_OUTPUT"
60+
environment:
61+
name: ${{ inputs.environment || 'Staging' }}
62+
url: ${{ steps.route.outputs.url }}

.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+
permissions:
9+
contents: read
10+
deployments: write
11+
12+
jobs:
13+
tests:
14+
uses: capire/xtravels-java/.github/workflows/test.yaml@main
15+
secrets: inherit
16+
deploy-cf:
17+
needs: [tests]
18+
uses: capire/xtravels-java/.github/workflows/cf.yaml@main
19+
secrets: inherit
20+
with:
21+
environment: Production

.github/workflows/test.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
pull_request:
7+
merge_group:
8+
push:
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
tests:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/setup-node@v5
20+
with:
21+
node-version: 22
22+
- uses: actions/checkout@v5
23+
- run: npm install
24+
- uses: actions/setup-java@v5
25+
with:
26+
distribution: sapmachine
27+
java-version: 21
28+
cache: maven
29+
- run: mvn test -B

0 commit comments

Comments
 (0)