@@ -15,27 +15,60 @@ jobs:
1515 build :
1616 runs-on : ubuntu-latest
1717 steps :
18- - uses : actions/checkout@v1
19- - name : Build the Docker image
20- run : docker build . -t build
21- - name : Testing image
22- shell : bash
23- working-directory : tests
24- run : |
25- docker build . -t test
26- docker run -d -p 8080:80 -p 8083:83 test
27- ./test.sh
28- docker stop $(docker ps -aq)
29- - name : Push the Docker image
30- if : github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
31- run : |
32- echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
33- function tag_and_push {
34- docker tag build "moeryomenko/ngxjs:${1}" && docker push "moeryomenko/ngxjs:${1}"
35- }
36- if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
37- tag_and_push "development"
38- elif [[ "${GITHUB_REF}" =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
18+ - name : Checkout
19+ uses : actions/checkout@v2
20+ # This is the a separate action that sets up buildx runner
21+ - name : Set up Docker Buildx
22+ uses : docker/setup-buildx-action@v1
23+ # So now you can use Actions' own caching!
24+ - name : Cache Docker layers
25+ uses : actions/cache@v2
26+ with :
27+ path : /tmp/.buildx-cache
28+ key : ${{ runner.os }}-buildx-${{ github.sha }}
29+ restore-keys : |
30+ ${{ runner.os }}-buildx-
31+ - name : Login to DockerHub
32+ uses : docker/login-action@v1
33+ with :
34+ username : ${{ secrets.DOCKER_USERNAME }}
35+ password : ${{ secrets.DOCKER_PASSWORD }}
36+ # And make it available for the builds
37+ - name : Build and push
38+ uses : docker/build-push-action@v2
39+ with :
40+ context : .
41+ push : false
42+ tags : moeryomenko/ngxjs:latest
43+ cache-from : type=local,src=/tmp/.buildx-cache
44+ cache-to : type=local,dest=/tmp/.buildx-cache-new
45+ # This ugly bit is necessary if you don't want your cache to grow forever
46+ # till it hits GitHub's limit of 5GB.
47+ # Temp fix
48+ # https://github.com/docker/build-push-action/issues/252
49+ # https://github.com/moby/buildkit/issues/1896
50+ - name : Move cache
51+ run : |
52+ rm -rf /tmp/.buildx-cache
53+ mv /tmp/.buildx-cache-new /tmp/.buildx-cache
54+ - name : Testing image
55+ shell : bash
56+ working-directory : tests
57+ run : |
58+ docker build . -t test
59+ docker run -d -p 8080:80 -p 8083:83 test
60+ ./test.sh
61+ docker stop $(docker ps -aq)
62+ - name : Push the Docker image
63+ if : github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
64+ run : |
65+ echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
66+ function tag_and_push {
67+ docker tag moeryomenko/ngxjs "moeryomenko/ngxjs:${1}" && docker push "moeryomenko/ngxjs:${1}"
68+ }
69+ if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
70+ tag_and_push "development"
71+ elif [[ "${GITHUB_REF}" =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
3972 TAG="${GITHUB_REF#"refs/tags/v"}"
4073 tag_and_push "${TAG}"
4174 if [[ "${TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
4780 tag_and_push "${TAG%.*.*}-ttn";
4881 tag_and_push "latest-ttn"
4982 fi
50- else
51- tag_and_push "${GITHUB_REF#"refs/tags/"}"
52- fi
83+ else
84+ tag_and_push "${GITHUB_REF#"refs/tags/"}"
85+ fi
0 commit comments