From f64e1d1bde1b42d70791c4b4da6d66fce7e27e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Sun, 25 Sep 2022 22:26:05 +0200 Subject: [PATCH] Deploy Docker image with GitHub Actions --- .github/workflows/deploy.yml | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2dec8fa --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,56 @@ +--- +name: Docker +on: + schedule: + - cron: "20 6 * * *" + workflow_run: + workflows: [ "pytest" ] + types: + - completed + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: | + thelovinator/discord-nice-embed-maker-for-my-yoy + ghcr.io/thelovinator1/discord-embed + flavor: latest=${{ github.ref == 'refs/heads/master' }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v2 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}