-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (65 loc) · 2.72 KB
/
main.yml
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
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
schedule:
- cron: '0 */6 * * *'
push:
branches: [ main ]
# pull_request:
# branches: [ master ]
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
# Runs a single command using the runners shell
- name: Generate cfn-cue specs
run: go run .
- name: files-changed
id: fileschanged
run: |
git diff --name-only
git diff --name-only | wc -l
echo ::set-output name=numfiles::$(git diff --name-only | wc -l)
shell: bash
- name: print files changed
run: echo ${{ steps.fileschanged.outputs.numfiles }}
- name: Get info
run: |
curl -L https://github.com/cuelang/cue/releases/download/v0.3.2/cue_v0.3.2_linux_amd64.tar.gz | tar -zxvf - cue; ls -al
CommitMessage=$(cat aws/uswest2/uswest2.cue | grep ResourceSpecificationVersion)
CFN_VERSION=$(echo $CommitMessage | ./cue eval - -e "#ResourceSpecificationVersion" --out text)
CUE_VERSION=$(go list -f "{{.Version}}" -m cuelang.org/go)
echo "CommitMessage=$CommitMessage" && echo "CFN_VERSION=$CFN_VERSION" && echo "CUE_VERSION=$CUE_VERSION"
echo "CommitMessage=$CommitMessage" >> $GITHUB_ENV
echo "CFN_VERSION=$CFN_VERSION" >> $GITHUB_ENV
echo "CUE_VERSION=$CUE_VERSION" >> $GITHUB_ENV
# if: steps.fileschanged.outputs.numfiles > 0
- name: print
run: echo "CommitMessage=$CommitMessage" && echo "CFN_VERSION=$CFN_VERSION" && echo "CUE_VERSION=$CUE_VERSION"
# if: steps.fileschanged.outputs.numfiles > 0
- name: git push
run: |
git config user.name github-actions
git config user.email [email protected]
git add -A
git commit -m "$CommitMessage"
git tag "$CUE_VERSION-$CFN_VERSION"
git push
git push --tags
if: steps.fileschanged.outputs.numfiles > 0