From e1302eb4fd7fd9a040d0c7a29eb002a6684247fc Mon Sep 17 00:00:00 2001 From: teddit Date: Fri, 26 Mar 2021 20:55:24 +0100 Subject: [PATCH] Merge pull request #3 from sethsimmons/main [PR FROM GITHUB] --- .github/dependabot.yml | 7 ++++ .github/workflows/update-base-image.yml | 46 ++++++++++++++++++++++ .github/workflows/update-image-on-push.yml | 45 +++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/update-base-image.yml create mode 100644 .github/workflows/update-image-on-push.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..583decf --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/update-base-image.yml b/.github/workflows/update-base-image.yml new file mode 100644 index 0000000..99ce779 --- /dev/null +++ b/.github/workflows/update-base-image.yml @@ -0,0 +1,46 @@ +name: "Update Image and Push to Github Packages and Docker Hub Daily" +on: + schedule: + - cron: "0 12 * * *" # Run every day at noon. + workflow_dispatch: +jobs: + rebuild-container: + name: "Rebuild Container with the latest base image" + runs-on: ubuntu-latest + steps: + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: "Checkout repository" + uses: "actions/checkout@v2" + - + name: Build and push to Docker Hub and Github Packages Docker Registry + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/teddit:latest + ${{ secrets.DOCKER_USERNAME }}/teddit:latest + labels: | + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.revision=${{ github.sha }} + cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/teddit:latest + cache-to: type=inline + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file diff --git a/.github/workflows/update-image-on-push.yml b/.github/workflows/update-image-on-push.yml new file mode 100644 index 0000000..d00eeff --- /dev/null +++ b/.github/workflows/update-image-on-push.yml @@ -0,0 +1,45 @@ +name: "Update Image and Push to Github Packages and Docker Hub when Dockerfile is changed" +# Run this workflow every time a new commit pushed to your repository +on: + push: +jobs: + rebuild-container: + name: "Rebuild Container with the latest base image" + runs-on: ubuntu-latest + steps: + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: "Checkout repository" + uses: "actions/checkout@v2" + - + name: Build and push to Docker Hub and Github Packages Docker Registry + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/teddit:latest + ${{ secrets.DOCKER_USERNAME }}/teddit:latest + labels: | + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.revision=${{ github.sha }} + cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/teddit:latest + cache-to: type=inline + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file