Skip to content

Commit c8e9d2f

Browse files
authored
Update docker.yml
1 parent 17156c4 commit c8e9d2f

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

.github/workflows/docker.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,27 @@ on:
77
- '**/*.yml'
88
branches:
99
- 'master'
10+
- 'dev'
1011

1112
jobs:
1213
docker:
1314
runs-on: ubuntu-latest
1415
steps:
16+
- name: Set env to staging
17+
if: endsWith(github.ref, '/dev')
18+
run: |
19+
echo "DOCKER_TAG=test" >> $GITHUB_ENV
20+
- name: Set env to production
21+
if: endsWith(github.ref, '/master')
22+
run: |
23+
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
1524
- name: Checkout
1625
uses: actions/checkout@v2
1726
- name: Set up QEMU
1827
uses: docker/setup-qemu-action@v1
1928
- name: Set up Docker Buildx
2029
uses: docker/setup-buildx-action@v1
21-
- name: Cache Docker layers
22-
uses: actions/cache@v2
23-
with:
24-
path: /tmp/.buildx-cache
25-
key: ${{ runner.os }}-buildx-${{ github.sha }}
26-
restore-keys: |
27-
${{ runner.os }}-buildx-
30+
2831
- name: Login to DockerHub
2932
uses: docker/login-action@v1
3033
with:
@@ -35,12 +38,6 @@ jobs:
3538
with:
3639
context: .
3740
push: true
38-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/djangoblog:latest
39-
cache-from: type=local,src=/tmp/.buildx-cache
40-
cache-to: type=local,dest=/tmp/.buildx-cache-new
41-
- name: Move cache
42-
run: |
43-
rm -rf /tmp/.buildx-cache
44-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
41+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/djangoblog:${{DOCKER_TAG}}
4542

4643

0 commit comments

Comments
 (0)