Publish #1049
This file contains hidden or 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
| name: Publish | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| paths-ignore: | |
| - .github/** | |
| schedule: | |
| - cron: "11 0 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| outputs: | |
| new_packages: ${{ steps.change_check.outputs.new_packages }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| token: ${{ secrets.UPDATING_GITHUB_TOKEN }} | |
| - name: Install AU dependencies | |
| run: choco install Chocolatey-AU -y | |
| - name: Update Terraform | |
| working-directory: ${{ github.workspace }}/terraform | |
| run: .\update.ps1 | |
| - name: Check for changes | |
| id: change_check | |
| env: | |
| BRANCH_NAME: ${{ github.ref_name }} | |
| run: | | |
| git fetch --depth=1 | |
| git checkout $env:BRANCH_NAME | |
| git add . | |
| $git_dirty=$(git diff --staged) | |
| if ($git_dirty.Count -eq 0) { | |
| echo "new_packages=false" >> $env:GITHUB_OUTPUT | |
| } else { | |
| echo "new_packages=true" >> $env:GITHUB_OUTPUT | |
| } | |
| - name: Commit and push changes | |
| if: ${{ steps.change_check.outputs.new_packages == 'true' }} | |
| env: | |
| COMMIT_MESSAGE: "Update Terraform Chocolatey packages" | |
| COMMIT_AUTHOR: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>" | |
| COMMIT_USER_NAME: "github-actions[bot]" | |
| COMMIT_USER_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" | |
| BRANCH_NAME: ${{ github.ref_name }} | |
| run: | | |
| echo "COMMIT_USER_NAME: $env:COMMIT_USER_NAME"; | |
| echo "COMMIT_USER_EMAIL: $env:COMMIT_USER_EMAIL"; | |
| echo "COMMIT_MESSAGE: $env:COMMIT_MESSAGE"; | |
| echo "COMMIT_AUTHOR: $env:COMMIT_AUTHOR"; | |
| git -c user.name="$env:COMMIT_USER_NAME" -c user.email="$env:COMMIT_USER_EMAIL" commit -m "$env:COMMIT_MESSAGE" --author="$env:COMMIT_AUTHOR" | |
| git push -u origin $env:BRANCH_NAME | |
| - name: Save Chocolatey packages | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: terraform | |
| path: "${{ github.workspace }}\\terraform\\*.nupkg" | |
| publish: | |
| runs-on: windows-latest | |
| needs: build | |
| if: ${{ needs.build.outputs.new_packages == 'true' }} | |
| steps: | |
| - name: Restore Choco package | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: terraform | |
| - name: Publish | |
| run: | | |
| choco apikey --key ${{secrets.CHOCO_API_KEY}} --source https://push.chocolatey.org/ | |
| foreach($file in (Get-ChildItem "." -Recurse -Include *.nupkg)) { | |
| choco push $file --source="'https://push.chocolatey.org/'" | |
| } |