-
Notifications
You must be signed in to change notification settings - Fork 3
46 lines (41 loc) · 1.31 KB
/
test-build-release.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
name: test-build-release
on: push
env:
IMAGE_TAG: ${{ github.sha }}
IMAGE: ${{ github.repository }}
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install bats
run: sudo apt-get -y install bats > /dev/null
- name: Run CI script
run: ./test/run.bats
release:
name: Create release
needs: tests
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Bump version and push tag
id: dump-version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push Docker image
run: |
DOCKERHUB_USERNAME=`echo "${IMAGE}" | awk -F"/" '{print $1}'`
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u $DOCKERHUB_USERNAME --password-stdin
# docker build
docker build -t ${IMAGE}:${{ steps.dump-version.outputs.new_tag }} . -f src/Dockerfile
# docker create latest tag
docker tag ${IMAGE}:${{ steps.dump-version.outputs.new_tag }} ${IMAGE}:latest
# docker push images
docker push --all-tags ${IMAGE}