forked from konveyor/move2kube
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (135 loc) · 5.2 KB
/
build.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Build
on:
push:
branches:
- "main"
- "release-*"
jobs:
build_and_test:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: info
uses: konveyor/get-env-info@v1
- uses: actions/setup-go@v2
with:
go-version: ${{ steps.info.outputs.go_version }}
- run: IN_CICD=true make ci
- run: make test-coverage
- name: upload coverage
uses: codecov/codecov-action@v1
- if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: "#BD3232"
SLACK_ICON: https://github.com/actions.png?size=48
SLACK_MESSAGE: "Build and test failed for move2kube ${{ github.ref }}"
SLACK_TITLE: Failed
SLACK_USERNAME: GitHubActions
run_move2kube_tests:
needs: [build_and_test]
name: Run move2kube tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: info
uses: konveyor/get-env-info@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: pull latest image to reuse layers
run: |
docker pull quay.io/konveyor/move2kube:latest || true
docker pull quay.io/konveyor/move2kube-builder:latest || true
- run: echo "${{ secrets.QUAY_BOT_PASSWORD }}" | docker login --username "${{ secrets.QUAY_BOT_USERNAME }}" --password-stdin quay.io
- name: build image
run: VERSION='${{ github.run_id }}' GO_VERSION='${{ steps.info.outputs.go_version }}' make cmultibuildpush
- name: run tests in move2kube-tests
uses: felixp8/[email protected]
with:
owner: konveyor
repo: move2kube-tests
token: ${{ secrets.MOVE2KUBE_PATOKEN }}
event_type: cli_build
client_payload: '{"tag": "${{ github.run_id }}", "commit_ref": "${{ github.ref }}"}'
wait_time: 5
max_time: 1200
- if: failure()
name: delete temporary image from quay
run: skopeo delete docker://quay.io/konveyor/move2kube:${{ github.run_id }}
- if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: "#BD3232"
SLACK_ICON: https://github.com/actions.png?size=48
SLACK_MESSAGE: "Tests on move2kube-tests failed for move2kube ${{ github.ref }}"
SLACK_TITLE: Failed
SLACK_USERNAME: GitHubActions
image_build:
needs: [run_move2kube_tests]
name: Image build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: info
uses: konveyor/get-env-info@v1
- id: image_tag
run: |
BRANCH="${GITHUB_REF#refs/heads/}"
if [ "$BRANCH" == 'main' ] ; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=$BRANCH" >> $GITHUB_OUTPUT
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: pull latest image to reuse layers
run: |
docker pull quay.io/konveyor/move2kube:latest || true
docker pull quay.io/konveyor/move2kube-builder:latest || true
docker pull quay.io/konveyor/move2kube:${{ github.run_id }}
- run: echo "${{ secrets.QUAY_BOT_PASSWORD }}" | docker login --username "${{ secrets.QUAY_BOT_USERNAME }}" --password-stdin quay.io
- name: build image
run: VERSION='${{ steps.image_tag.outputs.tag }}' GO_VERSION='${{ steps.info.outputs.go_version }}' make cmultibuildpush
- if: always()
name: delete temporary image from quay
run: skopeo delete docker://quay.io/konveyor/move2kube:${{ github.run_id }}
- name: trigger move2kube-api build
uses: actions/github-script@v3
with:
github-token: ${{ secrets.MOVE2KUBE_PATOKEN }}
script: |
const other_repo = 'move2kube-api';
const build_workflow = 'build.yml';
await github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: other_repo,
workflow_id: build_workflow,
ref: context.ref,
});
- name: success slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: https://github.com/actions.png?size=48
SLACK_MESSAGE: "Built and pushed quay.io/konveyor/move2kube:${{ steps.image_tag.outputs.tag }}"
SLACK_TITLE: Success
SLACK_USERNAME: GitHubActions
- if: failure()
name: failure slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: "#BD3232"
SLACK_ICON: https://github.com/actions.png?size=48
SLACK_MESSAGE: "Failed to build and push image quay.io/konveyor/move2kube:${{ steps.image_tag.outputs.tag }}"
SLACK_TITLE: Failed
SLACK_USERNAME: GitHubActions