|
| 1 | +name: Deploy Angular to GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +env: |
| 13 | + ANGULAR_APP_DIR: 'Clients/TalentManagement-Angular-Material/talent-management' |
| 14 | + BASE_HREF: '/AngularNetTutorial/' |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-deploy: |
| 18 | + name: Build and Deploy to GitHub Pages |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout repository (with submodules) |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + submodules: recursive |
| 26 | + |
| 27 | + - name: Set up Node.js |
| 28 | + uses: actions/setup-node@v4 |
| 29 | + with: |
| 30 | + node-version: '22.x' |
| 31 | + cache: 'npm' |
| 32 | + cache-dependency-path: '${{ env.ANGULAR_APP_DIR }}/package-lock.json' |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + working-directory: ${{ env.ANGULAR_APP_DIR }} |
| 36 | + run: npm ci |
| 37 | + |
| 38 | + - name: Inject production environment variables |
| 39 | + working-directory: ${{ env.ANGULAR_APP_DIR }} |
| 40 | + env: |
| 41 | + API_URL: ${{ secrets.API_APP_URL }} |
| 42 | + IDENTITY_SERVER_URL: ${{ secrets.IDENTITY_SERVER_URL }} |
| 43 | + run: | |
| 44 | + sed -i "s|https://your-production-api.com/api/v1|${API_URL}/api/v1|g" src/environments/environment.prod.ts |
| 45 | + sed -i "s|https://localhost:44310|${IDENTITY_SERVER_URL}|g" src/environments/environment.prod.ts |
| 46 | +
|
| 47 | + - name: Build Angular for GitHub Pages |
| 48 | + working-directory: ${{ env.ANGULAR_APP_DIR }} |
| 49 | + run: npm run build -- --configuration production --base-href "${{ env.BASE_HREF }}" |
| 50 | + |
| 51 | + - name: Add 404.html for SPA deep-link routing |
| 52 | + working-directory: ${{ env.ANGULAR_APP_DIR }}/dist/talent-management/browser |
| 53 | + run: cp index.html 404.html |
| 54 | + |
| 55 | + - name: Deploy to GitHub Pages |
| 56 | + uses: JamesIves/github-pages-deploy-action@v4 |
| 57 | + with: |
| 58 | + folder: ${{ env.ANGULAR_APP_DIR }}/dist/talent-management/browser |
| 59 | + branch: gh-pages |
| 60 | + clean: true |
0 commit comments