Skip to content

Commit

Permalink
Deploy only tags (#145)
Browse files Browse the repository at this point in the history
- Trigger docker-deploy only for release events
- Use docker/build-push-action to publish the docker image
- Remove scripts/deploy_docker.sh – this script relied on builds from the branches develop and master. For tags, it would pull the latest staging image and tag it (which we don't want since we want to build the tag and deploy it)
  • Loading branch information
fmrsabino authored Nov 16, 2021
1 parent b09ee4c commit f570a18
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 37 deletions.
55 changes: 36 additions & 19 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,43 @@ jobs:
docker-deploy:
runs-on: ubuntu-latest
needs: test-app
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')
if: github.event_name == 'release' && github.event.action == 'released'
steps:
- uses: actions/checkout@v2
- name: Dockerhub login
uses: docker/login-action@v1
- name: Checkout
uses: actions/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set tag (release)
# Set the tag versions as Docker tag if it is a release event
if: github.event_name == 'release' && github.event.action == 'released'
run: echo "DOCKER_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy Master
if: github.ref == 'refs/heads/master'
run: bash scripts/deploy_docker.sh staging
env:
DOCKERHUB_PROJECT: safe-notification-service
- name: Deploy Develop
if: github.ref == 'refs/heads/develop'
run: bash scripts/deploy_docker.sh develop
env:
DOCKERHUB_PROJECT: safe-notification-service
- name: Deploy Tag
if: startsWith(github.ref, 'refs/tags/')
run: bash scripts/deploy_docker.sh ${GITHUB_REF##*/}
env:
DOCKERHUB_PROJECT: safe-notification-service
- name: Build and push
id: docker_build
uses: docker/[email protected]
with:
context: .
push: true
tags: gnosispm/safe-notification-service:${{ env.DOCKER_TAG }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
18 changes: 0 additions & 18 deletions scripts/deploy_docker.sh

This file was deleted.

0 comments on commit f570a18

Please sign in to comment.