-
Notifications
You must be signed in to change notification settings - Fork 31
91 lines (73 loc) · 2.61 KB
/
Copy pathpublish.yml
File metadata and controls
91 lines (73 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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/'"
}