-
Notifications
You must be signed in to change notification settings - Fork 19
58 lines (56 loc) · 2.7 KB
/
post-push.yaml
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
name: Post Push Update
on:
workflow_call:
jobs:
post-push:
runs-on: ubuntu-latest
steps:
- name: get-default-branch
run: |
branch=$(curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
echo "default_branch=$branch" >> $GITHUB_ENV
- uses: 8BitJonny/gh-get-current-pr@2215326c76d51bfa3f2af0a470f32677f6c0cae9 # v2.2.0
id: PR
- name: checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0
with:
ref: ${{ env.default_branch }}
fetch-depth: 0
- name: init
run: |
docker run --rm -v $(pwd):/src -w /src mcr.microsoft.com/azterraform:latest make generate
- name: Yor Tag
id: yor-tag
run: |
docker run --rm -v $(pwd):/src -w /src mcr.microsoft.com/azterraform:latest make yor-tag
- name: update-changelog
run: |
MAJOR_VERSION=$(ls | grep CHANGELOG | cut -d'-' -f 2 | cut -f 1 -d '.' | grep v | sort -V -r | head -n 1)
if [ -z "$MAJOR_VERSION" ]; then
MAJOR_VERSION=0
else
MAJOR_VERSION=${MAJOR_VERSION#"v"}
MAJOR_VERSION=$((MAJOR_VERSION+1))
fi
previous_tag=$(docker run -e MAJOR_VERSION=$MAJOR_VERSION --rm mcr.microsoft.com/azterraform:latest previousTag ${{ github.repository_owner }} ${{ github.event.repository.name }} $MAJOR_VERSION.0.0)
if [ -z $previous_tag ]; then
docker run --rm -v $(pwd):/src -w /src githubchangeloggenerator/github-changelog-generator -u ${{ github.repository_owner }} -p ${{ github.event.repository.name }} -t ${{ secrets.GITHUB_TOKEN }} --no-issues --no-compare-link
else
docker run --rm -v $(pwd):/src -w /src githubchangeloggenerator/github-changelog-generator -u ${{ github.repository_owner }} -p ${{ github.event.repository.name }} -t ${{ secrets.GITHUB_TOKEN }} --no-issues --no-compare-link --since-tag=$previous_tag
fi
sudo chmod -R ugo+rwX .
- name: AutoFix
id: autofix
run: |
docker run --rm -v $(pwd):/src -w /src mcr.microsoft.com/azterraform:latest make autofix
- name: Terraform Validate
id: terraform-validate
run: |
docker run --rm -v $(pwd):/src -w /src mcr.microsoft.com/azterraform:latest sh -c "make pre-commit && make pr-check"
- name: Commit & Push changes
uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 # v1.4
if: ${{ github.repository != 'Azure/terraform-verified-module' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: 'Auto update'
branch: ${{ env.default_branch }}