Push stage images to dockerhub and redeploy stage #299
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push stage images to dockerhub and redeploy stage | |
on: | |
workflow_run: | |
workflows: | |
- "Run pytest based tests" | |
branches: | |
- master | |
types: | |
- completed | |
jobs: | |
push_stage_image_to_dockerhub: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
image: tonistiigi/binfmt:latest | |
platforms: linux/amd64,linux/arm64 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/#-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASS }} | |
- name: Cache | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: | | |
var-cache-pip | |
var-cache-apt | |
var-lib-apt | |
key: ${{ runner.os }}-cache-${{ hashFiles('Dockerfile') }} | |
- name: inject cache into docker | |
uses: reproducible-containers/buildkit-cache-dance@v3.1.2 | |
with: | |
cache-map: | | |
{ | |
"var-cache-pip": "/var/cache/pip", | |
"var-cache-apt": "/var/cache/apt", | |
"var-lib-apt": "/var/lib/apt" | |
} | |
skip-extraction: ${{ steps.cache.outputs.cache-hit }} | |
- name: Build and push stage twp-server image | |
uses: docker/build-push-action@v6 | |
with: | |
target: build | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
context: . | |
push: true | |
tags: rafsaf/twp-server:stage | |
platforms: linux/amd64,linux/arm64 | |
redeploy_stage: | |
runs-on: ubuntu-latest | |
needs: push_stage_image_to_dockerhub | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Redeploy stage server | |
run: | | |
curl -k -X POST https://${{ secrets.STAGE_HOOK_IP }}:9000/hooks/redeploy -H "Content-Type: application/json" -d '{"secret": "${{ secrets.STAGE_HOOK_SECRET }}"}' |