Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- testBranch | |
pull_request: | |
types: [opened, reopened, closed, labeled] | |
workflow_dispatch: # Enables manual trigger from GitHub UI | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Clone Incidents App Repository | |
run: git clone --branch e2eTest --single-branch https://github.com/cap-js/incidents-app.git && cd incidents-app | |
- name: Extract @cap-js/attachments version from PR | |
if: github.event_name == 'pull_request' | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
REPO=${{ github.repository }} | |
VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/files" | jq -r '.[] | select(.filename == "package.json") | .patch' | grep '"@cap-js/attachments":' | awk -F '"' '{print $4}') | |
echo "ATTACHMENTS_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Install @cap-js/attachments with PR version | |
if: env.ATTACHMENTS_VERSION != '' | |
run: | | |
cd incidents-app | |
npm install @cap-js/attachments@$ATTACHMENTS_VERSION | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: cd incidents-app && npm install | |
- name: Add HANA Configurations | |
run: cd incidents-app && npx cds add hana --for production | |
- name: Add XSUAA Configurations | |
run: cd incidents-app && npx cds add xsuaa --for production | |
- name: Build application for production | |
run: cd incidents-app && npx cds build --production | |
- name: Deploy using custom action | |
uses: ./.github/actions/deploy | |
with: | |
CF_API: ${{ secrets.CF_API }} | |
CF_USERNAME: ${{ secrets.CF_USERNAME }} | |
CF_PASSWORD: ${{ secrets.CF_PASSWORD }} | |
CF_ORG: ${{ secrets.CF_ORG }} | |
CF_SPACE: ${{ secrets.CF_SPACE }} | |
CF_APP_NAME: "incidents-app" | |
- name: Add comment to PR | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const pr = context.payload.pull_request; | |
const link = `https://${{ env.APP_URL }}`; | |
github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: pr.number, | |
body: `🚀 The application has been deployed to Cloud Foundry. You can access it [here](${link}).` | |
}); |