From ec9e78c6fd6e139fcc01db449c1be82c03cd4184 Mon Sep 17 00:00:00 2001 From: Einar-Johan Hansen Date: Sat, 10 Dec 2022 10:37:43 +0100 Subject: [PATCH] Add workflow for deployment This commit adds the workflow files that makes Github Actions build and push images to Docker Hub. --- .github/workflows/publish.yml | 33 ++++++++++++++++++++++++++++++ .github/workflows/pull_request.yml | 18 ++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..01ba734 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,33 @@ +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Checkout the repo + uses: actions/checkout@v3 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: einarhansen/php-runtime + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..94910aa --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,18 @@ +name: Verify pull request + +on: + pull_request: + +jobs: + build_image: + name: Build image + runs-on: ubuntu-latest + steps: + - name: Checkout the repo + uses: actions/checkout@v3 + + - name: Build docker image + uses: docker/build-push-action@v3 + with: + context: . + push: false