Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/cf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Cloud Foundry

on:
workflow_call:
inputs:
environment:
default: Staging
type: string
workflow_dispatch:
push:
branches:
- main
pull_request:

permissions:
contents: read
deployments: write
packages: read

concurrency:
group: cf-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
APP_NAME: xtravels
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORCE_COLOR: true
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 }}
22 changes: 22 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release

on:
workflow_dispatch:
release:
types: [published]

permissions:
contents: read
deployments: write
packages: read

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
32 changes: 32 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on:
workflow_call:
workflow_dispatch:
pull_request:
merge_group:
push:
branches:
- main

permissions:
contents: read
packages: read

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v5
with:
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
java-version: 21
cache: maven
- run: mvn test -B
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@capire:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
Loading