-
Notifications
You must be signed in to change notification settings - Fork 7
149 lines (139 loc) · 5.69 KB
/
ci.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
140
141
142
143
144
145
146
147
148
149
name: CI
on:
push:
branches: [main, ci]
tags: ['v*']
jobs:
# bumbailiff:
# name: "Bumbailiff - count technical debt"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - uses: actions/setup-node@v1
# with:
# node-version: 14.x
# - uses: egordm/gha-yarn-node-cache@v1
# - run: yarn install
# - run: yarn bumbailiff
test:
name: Test all packages
runs-on: ubuntu-latest
env:
GIT_ROOT: /git-repos
REDIS_URL: redis://localhost:6379
LOGGING_READABLE_BY: humans
ACTIONS_STEP_DEBUG: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
- uses: egordm/gha-yarn-node-cache@v1
- uses: supercharge/redis-github-action@1.4.0
- name: Install dependencies
run: yarn install
- name: Lint
run: yarn lint
- name: Build
run: yarn build
- name: Run tests in each workspace
run: yarn test
- name: Notify test failures
if: ${{ failure() }}
uses: archive/github-actions-slack@v2.4.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.CUCUMBERSTUDIO_SLACK_BOT_OAUTH_ACCESS_TOKEN }}
slack-channel: cucumberstudio-ci
slack-text: |
*git-en-boite*
:red_circle: Tests failed on main branch: <https://github.com/SmartBear/git-en-boite/commit/${{ github.sha }}>
publish-docker-image:
name: Build & publish Docker image
runs-on: ubuntu-latest
needs: [test]
env:
smoke_tests_web_server_url: http://git-en-boite:3001
smoke_tests_remote_repo_url: ${{ secrets.SMOKE_TESTS_CI_REMOTE_REPO_URL }}
GIT_EN_BOITE_IMAGE_VERSION: ${{ github.sha }}
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
steps:
- uses: actions/checkout@v3
- name: Get git tag name
id: tag
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
- name: Get short sha for build args
id: short-sha
run: echo ::set-output name=value::${GITHUB_SHA::7}
- name: BUILD -- Build smartbear/git-en-boite docker image
run: |
docker build \
--build-arg git_ref=${{ steps.short-sha.outputs.value }} \
--build-arg build_number=${{github.run_number}} \
--tag smartbear/git-en-boite:latest \
--tag smartbear/git-en-boite:${{ github.sha }} \
.
- name: BUILD -- Docker image tag - git-sha (unstable) or release?
id: docker-image-tag
run: echo ::set-output name=tag::smartbear/git-en-boite:${{ startsWith(github.ref, 'refs/tags/v') && steps.tag.outputs.tag || github.sha }}
- name: BUILD -- Add release tag to docker image
run: docker tag smartbear/git-en-boite:${{ github.sha }} ${{ steps.docker-image-tag.outputs.tag }}
- name: BUILD -- Set up qemu
uses: docker/setup-qemu-action@v1
- name: BUILD -- Set up buildx
uses: docker/setup-buildx-action@v1
- name: SMOKE TESTS -- Start services
run: docker-compose up --no-build --detach
- name: SMOKE TESTS -- Services start logs
run: docker-compose logs
- name: SMOKE TESTS -- Wait for services to be ready
uses: ifaxity/wait-on-action@v1
with:
resource: http://localhost:3001
timeout: 60000
verbose: true
- name: SMOKE TESTS -- Run smoke tests
run: docker-compose run smoke-tests yarn smoke start || (docker-compose log && exit 1)
- name: PUBLISH -- Authenticate with DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_KEY }}
- name: PUBLISH -- Push smartbear/git-en-boite
if: github.event_name == 'push'
run: docker push --all-tags smartbear/git-en-boite
- name: "REPORT -- Notify slack channel of build failure"
if: failure()
uses: archive/github-actions-slack@v2.4.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.CUCUMBERSTUDIO_SLACK_BOT_OAUTH_ACCESS_TOKEN }}
slack-channel: cucumberstudio-ci
slack-text: |
*git-en-boite*
:fire_engine: Docker image build failed <https://github.com/SmartBear/git-en-boite/commit/${{ github.sha }}>
- name: "REPORT -- Notify Slack channel of build success for a release"
if: success() && startsWith(github.ref, 'refs/tags/v')
uses: archive/github-actions-slack@v2.4.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.CUCUMBERSTUDIO_SLACK_BOT_OAUTH_ACCESS_TOKEN }}
slack-channel: cucumberstudio-ci
slack-text: |
*git-en-boite*
:truck: New release image published: "${{ steps.docker-image-tag.outputs.tag }}"
- name: "REPORT -- Nofify SmartBear infrastructure of new container image"
if: success()
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.SWAG_BOT_TOKEN }}
repository: smartbear/git-en-boite-infra
event-type: container-image-published
client-payload: '{"image_tag": "${{ steps.docker-image-tag.outputs.tag }}"}'
- name: "REPORT -- Nofify SmartBear infrastructure of new production container image"
if: success() && startsWith(github.ref, 'refs/tags/v')
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.SWAG_BOT_TOKEN }}
repository: smartbear/git-en-boite-infra
event-type: production-container-image-published
client-payload: '{"image_tag": "${{ steps.docker-image-tag.outputs.tag }}"}'