From 9f00df19753dfab21cea07de9e363f160ac40f3e Mon Sep 17 00:00:00 2001 From: Steffen Waldmann Date: Wed, 17 Dec 2025 12:00:22 +0100 Subject: [PATCH 1/6] `cds add github-actions` --- .github/workflows/cf.yaml | 62 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yaml | 21 ++++++++++++ .github/workflows/test.yaml | 29 ++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 .github/workflows/cf.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/cf.yaml b/.github/workflows/cf.yaml new file mode 100644 index 0000000..d9b159b --- /dev/null +++ b/.github/workflows/cf.yaml @@ -0,0 +1,62 @@ +name: Cloud Foundry + +on: + workflow_call: + inputs: + environment: + default: Staging + type: string + workflow_dispatch: + push: + branches: + - main + +permissions: + contents: read + deployments: write + +concurrency: + group: cf-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + APP_NAME: xtravels +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 + with: + node-version: 22 + - uses: actions/setup-java@v5 + with: + distribution: sapmachine + java-version: 21 + cache: maven + - uses: cap-js/cf-setup@v1 + with: + cf-api: ${{ vars.CF_API }} + cf-org: ${{ vars.CF_ORG }} + cf-space: ${{ vars.CF_SPACE }} + cf-username: ${{ vars.CF_USERNAME }} + cf-password: ${{ secrets.CF_PASSWORD }} + - run: npm install + - run: npx cds up + + - run: cf logs "${{ env.APP_NAME }}" --recent + if: always() + - run: cf logs "${{ env.APP_NAME }}-srv" --recent + if: always() + - run: cf logs "${{ env.APP_NAME }}-db-deployer" --recent + if: always() + + - name: Get application URL + id: route + shell: bash + run: | + host=$(cf app "${APP_NAME}" | awk '/routes:/ {print $2}' | sed -E 's#^https?://##; s/,.*$//') + echo "url=https://$host" >> "$GITHUB_OUTPUT" + environment: + name: ${{ inputs.environment || 'Staging' }} + url: ${{ steps.route.outputs.url }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..326da44 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,21 @@ +name: Release + +on: + workflow_dispatch: + release: + types: [published] + +permissions: + contents: read + deployments: write + +jobs: + tests: + uses: capire/xtravels-java/.github/workflows/test.yaml@main + secrets: inherit + deploy-cf: + needs: [tests] + uses: capire/xtravels-java/.github/workflows/cf.yaml@main + secrets: inherit + with: + environment: Production diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..88ea15d --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,29 @@ +name: Tests + +on: + workflow_call: + workflow_dispatch: + pull_request: + merge_group: + push: + branches: + - main + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v5 + with: + node-version: 22 + - uses: actions/checkout@v5 + - run: npm install + - uses: actions/setup-java@v5 + with: + distribution: sapmachine + java-version: 21 + cache: maven + - run: mvn test -B From 3e7290d7622fd2452ba950bd65637388239f4396 Mon Sep 17 00:00:00 2001 From: Steffen Waldmann Date: Wed, 17 Dec 2025 12:37:16 +0100 Subject: [PATCH 2/6] Add pull_request trigger to cf.yaml workflow --- .github/workflows/cf.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cf.yaml b/.github/workflows/cf.yaml index d9b159b..c3e75ac 100644 --- a/.github/workflows/cf.yaml +++ b/.github/workflows/cf.yaml @@ -10,6 +10,7 @@ on: push: branches: - main + pull_request: permissions: contents: read From aa492fcf92982a64c6c1c671a912847a5f149509 Mon Sep 17 00:00:00 2001 From: Steffen Waldmann Date: Wed, 17 Dec 2025 12:41:10 +0100 Subject: [PATCH 3/6] Add `packages` permission --- .github/workflows/cf.yaml | 1 + .github/workflows/release.yaml | 1 + .github/workflows/test.yaml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/cf.yaml b/.github/workflows/cf.yaml index d9b159b..17dfe2b 100644 --- a/.github/workflows/cf.yaml +++ b/.github/workflows/cf.yaml @@ -14,6 +14,7 @@ on: permissions: contents: read deployments: write + packages: read concurrency: group: cf-${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 326da44..7395d61 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,6 +8,7 @@ on: permissions: contents: read deployments: write + packages: read jobs: tests: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 88ea15d..d14ed5c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,6 +11,7 @@ on: permissions: contents: read + packages: read jobs: tests: From 305e1bbebf82aecc371d439c8015d2989bafe322 Mon Sep 17 00:00:00 2001 From: Steffen Waldmann Date: Wed, 17 Dec 2025 13:41:33 +0100 Subject: [PATCH 4/6] Add NODE_AUTH_TOKEN --- .github/workflows/cf.yaml | 1 + .github/workflows/test.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/cf.yaml b/.github/workflows/cf.yaml index d0109d5..fc8e0cf 100644 --- a/.github/workflows/cf.yaml +++ b/.github/workflows/cf.yaml @@ -23,6 +23,7 @@ concurrency: env: APP_NAME: xtravels + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: deploy: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d14ed5c..ebbf368 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,6 +22,8 @@ jobs: node-version: 22 - uses: actions/checkout@v5 - run: npm install + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-java@v5 with: distribution: sapmachine From 006a4abb6d07abcff03a15b9227679bcd2db478a Mon Sep 17 00:00:00 2001 From: Steffen Waldmann Date: Wed, 17 Dec 2025 13:44:15 +0100 Subject: [PATCH 5/6] Update .npmrc --- .npmrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmrc b/.npmrc index 77ed8bc..217fb77 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ @capire:registry=https://npm.pkg.github.com/ +//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN} From c3addcd1e3b95c9a05e694334a5d76cdac1b1916 Mon Sep 17 00:00:00 2001 From: Steffen Waldmann Date: Wed, 17 Dec 2025 14:22:34 +0100 Subject: [PATCH 6/6] Set `FORCE_COLOR` --- .github/workflows/cf.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cf.yaml b/.github/workflows/cf.yaml index fc8e0cf..3364b8f 100644 --- a/.github/workflows/cf.yaml +++ b/.github/workflows/cf.yaml @@ -24,6 +24,7 @@ concurrency: env: APP_NAME: xtravels NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FORCE_COLOR: true jobs: deploy: runs-on: ubuntu-latest