Skip to content

Create and publish a Docker image #45

Create and publish a Docker image

Create and publish a Docker image #45

Workflow file for this run

name: Create and publish a Docker image
on:
workflow_dispatch:
push:
branches: [master]
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
docker:
runs-on: ubuntu-latest
strategy:
matrix:
app: [PlaygroundClient, PlaygroundSilo]
if: github.ref_type != 'tag'
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/orleans-${{ matrix.app }}
tags: |
type=sha
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.${{ matrix.app }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: docker
if: ${{ !(failure() || cancelled()) }}
runs-on: ubuntu-latest
env:
ENVIRONMENT: ${{ github.ref_type == 'tag' && 'production' || 'development' }}
steps:
- uses: actions/checkout@v4
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "short_sha=$calculatedSha" >> "$GITHUB_OUTPUT"
- name: Deploy
uses: actions/github-script@v6
with:
github-token: ${{ secrets.WORKFLOW_DISPATCH }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'poc-aaa',
repo: 'devops',
workflow_id: 'playground-autoscaler-deploy.yaml',
ref: 'main',
inputs: {
env: '${{ env.ENVIRONMENT }}',
appName: 'orleans-playground-service',
commit_sha: 'sha-${{ steps.vars.outputs.short_sha }}',
}
})