|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + paths-ignore: |
| 6 | + - CHANGELOG.md |
| 7 | + - .vscode/** |
| 8 | + - .github/** |
| 9 | + - images/** |
| 10 | + - tests/** |
| 11 | + - '**.md' |
| 12 | + - '**.yml' |
| 13 | + tags: |
| 14 | + - '*' |
| 15 | +env: |
| 16 | + buildFolderName: output |
| 17 | + buildArtifactName: output |
| 18 | + |
| 19 | +permissions: |
| 20 | + actions: write # to allow the workflow to run actions |
| 21 | + checks: write # to allow the workflow to create checks |
| 22 | + statuses: write # to allow the workflow to create statuses |
| 23 | + |
| 24 | +name: Deploy Module (only) |
| 25 | +# This workflow is triggered on push to the main branch and deploys the module to the PowerShell Gallery and creates a GitHub Release. |
| 26 | +jobs: |
| 27 | + Build_Stage_Package_Module: |
| 28 | + name: Package Module |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout Code |
| 32 | + uses: actions/checkout@v3 |
| 33 | + with: |
| 34 | + ref: ${{ github.head_ref }} # checkout the triggered ref (branch or tag) |
| 35 | + fetch-depth: 0 |
| 36 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + - name: Build & Package Module |
| 38 | + shell: pwsh |
| 39 | + run: ./build.ps1 -ResolveDependency -tasks pack |
| 40 | + - name: Publish Build Artifact |
| 41 | + uses: actions/upload-artifact@v4 |
| 42 | + with: |
| 43 | + name: ${{ env.buildArtifactName }} |
| 44 | + path: ${{ env.buildFolderName }}/ |
| 45 | + |
| 46 | + Deploy_Stage_Deploy_Module: |
| 47 | + name: Deploy Module |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: |
| 50 | + - Build_Stage_Package_Module |
| 51 | + if: ${{ success() && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} |
| 52 | + steps: |
| 53 | + - name: Checkout Code |
| 54 | + uses: actions/checkout@v3 |
| 55 | + with: |
| 56 | + ref: ${{ github.head_ref }} # checkout the triggered ref (branch or tag) |
| 57 | + fetch-depth: 0 |
| 58 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + - name: Download Build Artifact |
| 60 | + uses: actions/download-artifact@v4 |
| 61 | + with: |
| 62 | + name: ${{ env.buildArtifactName }} |
| 63 | + path: ${{ env.buildFolderName }} |
| 64 | + - name: Publish Release |
| 65 | + shell: pwsh |
| 66 | + run: ./build.ps1 -tasks publish |
| 67 | + env: |
| 68 | + GitHubToken: ${{ secrets.GitHubToken }} |
| 69 | + GalleryApiToken: ${{ secrets.GalleryApiToken }} |
0 commit comments