Skip to content

Commit

Permalink
feat: Add github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatanaatos committed Oct 4, 2024
1 parent fcdffcd commit 4df04ac
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
69 changes: 69 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI
on:
push:
release:
types: [published]

permissions:
id-token: write
contents: read
env:
# Change this to upload the built image to your own organization.
docker_image: ghcr.io/tietokilta/rekry-tg-hook
jobs:
docker-build-and-push:
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'release' && github.event.action == 'published')
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{env.docker_image}}
tags: |
type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref_type == 'tag' }}
type=raw,value=sha-${{github.sha}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Push to GitHub Packages
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=min

deploy:
# only run on published releases, enable this when we release
#if: github.event_name == 'release' && github.event.action == 'published'
name: Deploy to Azure
runs-on: ubuntu-latest
needs: docker-build-and-push
environment: production
steps:
- name: Login via Azure CLI
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Run Azure Functions Container Action'
uses: Azure/functions-container-action@v1
with:
app-name: tik-rekry-tg-bot-prod
image: "${{ env.docker_image }}:sha-${{ github.sha }}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ COPY . .
EXPOSE 8000

# Run the FastAPI application with Uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

0 comments on commit 4df04ac

Please sign in to comment.