Skip to content

Commit

Permalink
chore: build and push Docker image on tags
Browse files Browse the repository at this point in the history
* git tags starting with "v" (eg. v0.1.0) will result in a
  italia/developers-italia-onboarding:v0.1.0 image.
* Commits to master will result in
  italia/developers-italia-onboarding:master
* Both will create a italia/developers-italia-onboarding:{sha} tag
  • Loading branch information
bfabio committed Apr 15, 2021
1 parent ba72b3e commit ea77fa9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/test_and_publish_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
name: ci

jobs:
test_and_publish_docker_image:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
Expand All @@ -24,16 +24,31 @@ jobs:
- run: npm run lint
- run: npm run test

build_and_publish_docker_image:
needs: test

runs-on: ubuntu-latest

if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get Docker image tags
id: image_tags
run: |
IMAGE=italia/developers-italia-onboarding
TAGS=${IMAGE}:$(echo ${GITHUB_REF##*/})
TAGS="$TAGS,${IMAGE}:${GITHUB_SHA::8}"
echo ::set-output name=tags::${TAGS}
- name: Build and push
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v2
with:
push: true
tags: italia/developers-italia-onboarding:staging
tags: ${{ steps.image_tags.outputs.tags }}

0 comments on commit ea77fa9

Please sign in to comment.