-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (72 loc) · 2.25 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
name: CI
on:
push:
branches: [master]
tags: [v*]
pull_request:
branches: [master]
jobs:
test:
name: All checks are passed
uses: ./.github/workflows/test.yaml
approve:
name: Approve bot PR
runs-on: ubuntu-latest
if: endsWith(github.actor, '[bot]')
needs: test
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: metadata
id: metadata
if: github.actor == 'dependabot[bot]'
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge for bot PRs
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
name: Build and push Docker image
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout commit
uses: actions/checkout@v4
- name: Sanity check for tag and version
run: |
export VERSION=${{ needs.test.outputs.version }}
if [ "${{ github.ref }}" != "refs/tags/v$VERSION" ]
then
echo "Git tag '${{ github.ref }}' differs from hard-coded package version 'v$VERSION'"
exit 1
else
echo "OK, git tag matches hard-coded package version: 'v$VERSION'"
fi
- name: Login to Github container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
env:
VERSION: ${{ needs.test.outputs.version }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
docker build \
-t "ghcr.io/neuro-inc/wabucketref:${VERSION}" \
-t "ghcr.io/neuro-inc/wabucketref:latest" \
--build-arg COMMIT_SHA=${COMMIT_SHA} \
.
- name: Push
env:
VERSION: ${{ needs.test.outputs.version }}
run: |
docker push ghcr.io/neuro-inc/wabucketref --all-tags