Skip to content

Commit

Permalink
fix: try to publish docker on push tags v* (#1430)
Browse files Browse the repository at this point in the history
* fix: try to publish docker on push tags v*
  • Loading branch information
razvan-pro committed Dec 8, 2020
1 parent b2be045 commit f6bebfe
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 65 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,71 +175,6 @@ jobs:
branch: ${{ steps.branch.outputs.branch }}
build: ${{ github.run_number }}

publish-docker-images:
name: Publish aimmo Docker images
if: github.event_name == 'push' && github.event.head_commit.author.email == 'action@github.com' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set docker tag
id: docker_tag
run: |
echo "::set-output name=tag::${GITHUB_REF:11}" # this is either branch name or tag after first character ('v')
- name: Build and push aimmo-game image
id: game
uses: docker/build-push-action@v2
with:
context: aimmo-game
file: aimmo-game/Dockerfile
tags: ocadotechnology/aimmo-game:${{ steps.docker_tag.outputs.tag }}
target: runner
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Build and push aimmo-game-creator image
id: game_creator
uses: docker/build-push-action@v2
with:
context: aimmo-game-creator
file: aimmo-game-creator/Dockerfile
tags: ocadotechnology/aimmo-game-creator:${{ steps.docker_tag.outputs.tag }}
target: runner
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: |
echo ${{ steps.game.outputs.digest }}
echo ${{ steps.game_creator.outputs.digest }}
notify-semaphore:
name: Notify Semaphore
needs: [publish-python, publish-docker-images]
runs-on: ubuntu-18.04
steps:
- name: Notify Semaphore (Staging)
run: curl -d POST -v https://semaphoreci.com/api/v1/projects/${SEMAPHORE_PROJECT_ID}/master/build?auth_token=${SEMAPHORE_API_AUTH}
env:
SEMAPHORE_PROJECT_ID: ${{ secrets.SEMAPHORE_PROJECT_ID }}
SEMAPHORE_API_AUTH: ${{ secrets.SEMAPHORE_API_AUTH }}

merge-master-into-development:
name: Merge master into development after release
needs: [publish-python]
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/publish-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish Docker images
on:
push:
tags:
- "v*"
jobs:
publish-docker-images:
name: Publish aimmo Docker images
if: github.event.head_commit.author.email == 'action@github.com'
runs-on: ubuntu-18.04
steps:
- name: "[Debug] Print github.ref"
run: echo "${{ github.ref }}"
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set docker tag
id: docker_tag
run: |
echo "::set-output name=tag::${GITHUB_REF:11}" # this is either branch name or tag after first character ('v')
- name: Build and push aimmo-game image
id: game
uses: docker/build-push-action@v2
with:
context: aimmo-game
file: aimmo-game/Dockerfile
tags: ocadotechnology/aimmo-game:${{ steps.docker_tag.outputs.tag }}
target: runner
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Build and push aimmo-game-creator image
id: game_creator
uses: docker/build-push-action@v2
with:
context: aimmo-game-creator
file: aimmo-game-creator/Dockerfile
tags: ocadotechnology/aimmo-game-creator:${{ steps.docker_tag.outputs.tag }}
target: runner
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: |
echo ${{ steps.game.outputs.digest }}
echo ${{ steps.game_creator.outputs.digest }}
notify-semaphore:
name: Notify Semaphore
needs: [publish-docker-images]
runs-on: ubuntu-18.04
steps:
- name: Notify Semaphore (Staging)
run: curl -d POST -v https://semaphoreci.com/api/v1/projects/${SEMAPHORE_PROJECT_ID}/master/build?auth_token=${SEMAPHORE_API_AUTH}
env:
SEMAPHORE_PROJECT_ID: ${{ secrets.SEMAPHORE_PROJECT_ID }}
SEMAPHORE_API_AUTH: ${{ secrets.SEMAPHORE_API_AUTH }}

0 comments on commit f6bebfe

Please sign in to comment.