Skip to content

Build & Deploy

Build & Deploy #179

Workflow file for this run

name: Build & Deploy
on:
workflow_run:
workflows: ['CI']
branches: [master]
types:
- completed
jobs:
docker:
permissions:
packages: write
contents: read
name: Publish - Docker hub
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
timeout-minutes: 10
env:
REPO: ghcr.io/akimitsulebot/bilderna
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Build Docker image
run: docker build -t $REPO:latest -t $REPO:${GITHUB_SHA::8} .
- name: Login to Docker Hub
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Publish Docker image
run: docker push $REPO
deploy:
name: Call deploy script
runs-on: ubuntu-latest
needs: docker
steps:
- name: Trigger ansible playbook
env:
REPO_OWNER: "AkimitsuLeBot"
REPO_NAME: "${{ secrets.DEPLOY_REPO }}"
EVENT_TYPE: "deploy-bilderna"
run: |
curl -L \
-X POST \
--fail-with-body \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/dispatches \
-d "{\"event_type\": \"$EVENT_TYPE\"}"