Skip to content

Build & publish Docker image for dev #77

Build & publish Docker image for dev

Build & publish Docker image for dev #77

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Build & publish Docker image for dev
on:
workflow_dispatch:
workflow_run:
workflows: [Build & Test Node app (CI) for dev]
types: [completed]
branches: [dev, gpt-3.5-model]
concurrency:
group: ${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
permissions:
contents: 'read'
packages: 'write'
jobs:
build-publish-docker:
runs-on: ubuntu-latest
environment: dev
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.9.1
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Log in to GitHub container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Lowercase the repo name
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Get friendly branch name
run: |
branchName=${{ github.event.workflow_run.head_branch }}
echo "BRANCH_NAME_FRIENDLY=$(echo "$branchName" | tr '[:upper:]' '[:lower:]' | sed -e 's/[^a-zA-Z0-9.]//g' -e 's/\./-/g')" >>${GITHUB_ENV}
- name: Build and push container image to GitHub/Azure registry
uses: docker/build-push-action@v4
with:
provenance: false
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/pfa-discord-bot-gpt-${{ github.event.workflow_run.head_branch }}:latest
ghcr.io/${{ env.REPO }}-${{ github.event.workflow_run.head_branch }}:latest
file: ./Dockerfile
- name: 'Deploy to Azure Container Instances'
uses: 'azure/aci-deploy@v1'
with:
resource-group: ${{ secrets.AZURE_RESOURCE_GROUP }}
dns-name-label: pfa-discord-bot-${{ env.BRANCH_NAME_FRIENDLY }}
image: ghcr.io/${{ env.REPO }}-${{ github.event.workflow_run.head_branch }}:latest
registry-login-server: ghcr.io
registry-username: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
name: pfa-discord-bot-container-${{ env.BRANCH_NAME_FRIENDLY }}
secure-environment-variables: |
DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}
OPENAI_KEY=${{ secrets.OPENAI_KEY }}
OPENAI_ORG=${{ secrets.OPENAI_ORG }}
location: 'northeurope'