Merge pull request #13 from stautonico/dev #25
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: Deploy images to GHCR | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push-images: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
actions: read | |
checks: read | |
deployments: read | |
pull-requests: read | |
repository-projects: read | |
statuses: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build the web and nginx docker images | |
run: | | |
CODE_HASH=$(find proxycroak \( -type d -name .mypy_cache -prune \) -o \( -type d -name __pycache__ -prune \) -o \( -type f -not -name "*.log" -not -name "*.webp" -exec sha256sum {} \; \) | sort | sha256sum | awk '{print $1}') | |
echo $CODE_HASH | |
# Build the nginx container | |
docker build -t proxycroak-nginx nginx | |
# Build the proxycroak flask app | |
docker build -t proxycroak-web . --build-arg CODE_HASH=$CODE_HASH | |
- name: Tag the Docker images | |
run: | | |
docker tag proxycroak-web ${{ env.REGISTRY }}/${{ github.actor }}/proxycroak-web:latest | |
docker tag proxycroak-nginx ${{ env.REGISTRY }}/${{ github.actor }}/proxycroak-nginx:latest | |
- name: Push Docker Images to GHCR | |
run: | | |
docker push ${{ env.REGISTRY}}/${{ github.actor }}/proxycroak-web:latest | |
docker push ${{ env.REGISTRY}}/${{ github.actor }}/proxycroak-nginx:latest | |
- name: Extract PR Info | |
uses: 8BitJonny/gh-get-current-pr@master | |
id: PR | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
sha: ${{ github.event.pull_request.head.sha }} | |
filterOutClosed: false | |
filterOutDraft: true | |
- name: Send Discord notification | |
if: success() && steps.PR.outputs.number | |
env: | |
prTitle: ${{ steps.PR.outputs.pr_title }} | |
prBody: ${{ steps.PR.outputs.pr_body }} | |
uses: tsickert/[email protected] | |
with: | |
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
content: "<@&1190582363340685424> **New release!**" | |
embed-title: "Proxycroak ${{env.prTitle}}" | |
embed-description: "${{env.prBody}}" | |
embed-url: "https://proxycroak.com/changelog#${{env.prTitle}}" | |
embed-thumbnail-url: "https://proxycroak.com/static/img/favicons/favicon-196x196.png" | |
embed-color: "5763719" | |