diff --git a/workflows/build.yml b/workflows/build.yml new file mode 100644 index 0000000..371a4bd --- /dev/null +++ b/workflows/build.yml @@ -0,0 +1,73 @@ +name: Build and Release Angular App + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm install + + - name: Build the Angular app + run: npm run build + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: angular-app + path: dist/angular-app + + release: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: angular-app + path: dist/angular-app + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.sha }} + release_name: Release ${{ github.sha }} + draft: false + prerelease: false + + - name: Upload build artifact to Release + uses: actions/upload-release-asset@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/angular-app + asset_name: angular-app.zip + asset_content_type: application/zip