-
Notifications
You must be signed in to change notification settings - Fork 2
52 lines (47 loc) · 1.61 KB
/
docker-image.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
name: Docker Image CI
on:
push:
branches: [master]
paths:
- .devcontainer/base.Dockerfile
- .devcontainer/Dockerfile
pull_request:
branches: [master]
paths:
- .devcontainer/base.Dockerfile
- .devcontainer/Dockerfile
release:
types: [published, edited]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set env for PR branch
id: branch_vars
if: ${{ startsWith(github.ref, 'refs/pull/') }}
run: |
echo "image_tag=dev" >> $GITHUB_ENV
echo "meteor_release=latest" >> $GITHUB_ENV
- name: Set env for master branch
id: master_vars
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "image_tag=latest" >> $GITHUB_ENV
echo "meteor_release=latest" >> $GITHUB_ENV
- name: Set env for github release
id: release_vars
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
VERSION=$(echo $GITHUB_REF | sed "s/refs\/tags\/v\(.*\)/\1/")
echo "image_tag=$VERSION" >> $GITHUB_ENV
echo "meteor_release=$VERSION" >> $GITHUB_ENV
- name: Build docker image
run: docker build .devcontainer --file .devcontainer/base.Dockerfile --build-arg RELEASE="${{ env.meteor_release }}" --tag "meteorengineer/meteor-devcontainer:${{ env.image_tag }}"
- name: Push docker image
run: docker push "meteorengineer/meteor-devcontainer:${{ env.image_tag }}"