probably fixed /votes #112
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 Docker Image | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check for existing cache | |
id: cache-check | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.ref }}-${{ hashFiles('Dockerfile', 'requirements.txt') }} | |
- name: Delete old caches if no cache found | |
if: steps.cache-check.outputs.cache-hit != 'true' | |
env: | |
GH_TOKEN: ${{ secrets.FOR_CACHE_REPO_PAT }} | |
run: | | |
if gh cache list --repo probablyjassin/bot-mk8dx | grep -q 'buildx'; then | |
gh cache delete --all --repo probablyjassin/bot-mk8dx | |
else | |
echo "No caches to delete." | |
fi | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
path: | | |
/tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.ref }}-${{ hashFiles('Dockerfile', 'requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ghcr.io/probablyjassin/mk8dx-yuzu-bot:latest | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache |