From 64f4dc204fb6029640c7df6d78bef404fbda38d2 Mon Sep 17 00:00:00 2001 From: Thomas Fini Hansen Date: Mon, 28 Mar 2022 17:41:00 +0200 Subject: [PATCH] Add Github Action to build and push image --- .github/workflows/docker-release.yml | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/docker-release.yml diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..c632171 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,41 @@ +on: push + +name: Docker build and push +jobs: + + build: + name: Docker build and push + # Only run on default branch. + if: > + ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + - name: Build and push Docker images + uses: docker/build-push-action@v2 + with: + file: Dockerfile + builder: ${{ steps.buildx.outputs.name }} + push: true + context: . + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.version=${{ github.sha }} + org.opencontainers.image.revision=${{ github.sha }} + tags: | + ghcr.io/${{ github.repository }}:latest + reload/drupal-apache-fpm:latest