Skip to content

Commit cdca2c7

Browse files
authored
Add GitHub Actions deployment (#23)
1 parent 655c9d7 commit cdca2c7

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

.github/workflows/cf.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
packages: read
18+
19+
concurrency:
20+
group: cf-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21+
cancel-in-progress: true
22+
23+
env:
24+
APP_NAME: xflights
25+
FORCE_COLOR: true
26+
jobs:
27+
deploy:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v6
31+
- uses: actions/setup-node@v6
32+
with:
33+
node-version: 22
34+
registry-url: https://npm.pkg.github.com/
35+
- uses: actions/setup-java@v5
36+
with:
37+
distribution: sapmachine
38+
java-version: 21
39+
cache: maven
40+
- uses: cap-js/cf-setup@v2
41+
with:
42+
api: ${{ vars.CF_API }}
43+
org: ${{ vars.CF_ORG }}
44+
space: ${{ vars.CF_SPACE }}
45+
username: ${{ vars.CF_USERNAME }}
46+
password: ${{ secrets.CF_PASSWORD }}
47+
- run: npm install
48+
env:
49+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
50+
51+
- run: npx cds up
52+
53+
- run: cf logs "${{ env.APP_NAME }}-srv" --recent
54+
if: always()
55+
- run: cf logs "${{ env.APP_NAME }}-db-deployer" --recent
56+
if: always()
57+
58+
- name: Get backend URL
59+
id: route
60+
shell: bash
61+
run: |
62+
host=$(cf app "${APP_NAME}-srv" | awk '/routes:/ {print $2}' | sed -E 's#^https?://##; s/,.*$//')
63+
echo "url=https://$host" >> "$GITHUB_OUTPUT"
64+
environment:
65+
name: ${{ inputs.environment || 'Staging' }}
66+
url: ${{ steps.route.outputs.url }}

.github/workflows/release.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
permissions:
9+
contents: read
10+
deployments: write
11+
packages: read
12+
13+
jobs:
14+
tests:
15+
uses: capire/xflights-java/.github/workflows/maven.yaml@main
16+
secrets: inherit
17+
deploy-cf:
18+
needs: [tests]
19+
uses: capire/xflights-java/.github/workflows/cf.yaml@main
20+
secrets: inherit
21+
with:
22+
environment: Production

0 commit comments

Comments
 (0)