From 37a37aa2beca3708df07f0e66885accedf48d256 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Tue, 12 Mar 2024 10:34:34 -0300 Subject: [PATCH 1/3] feat: github actions are quicker --- .github/workflows/docker-build.yaml | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/docker-build.yaml diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..772777c --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,38 @@ +name: Publish Docker image + +on: + push: + branches: ["master", "php*"] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + + permissions: + packages: write + contents: read + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: lojassimonetti/php-apache-oci8-composer + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 2f7e1912358912a0b83c2a8c30d79e922d9c8568 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Tue, 12 Mar 2024 10:41:59 -0300 Subject: [PATCH 2/3] fix: php\ddot\d --- .github/workflows/docker-build.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 772777c..767c4ef 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -29,10 +29,19 @@ jobs: with: images: lojassimonetti/php-apache-oci8-composer + - name: Should push? + id: shoudPush + run: | + if [[ ${{ github.event.ref }} =~ ^refs/tags/php[0-9]dot[0-9]$ ]]; then + echo "match=true" >> $GITHUB_OUTPUT + elif [[ ${{ github.event.ref }} = "master" ]]; then + echo "match=true" >> $GITHUB_OUTPUT + fi + - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . - push: true + push: ${{ steps.shoudPush.outputs.match == 'true' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From afc740dc31e98997f7b5e9e1dd929e2119111d6a Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Tue, 12 Mar 2024 10:55:12 -0300 Subject: [PATCH 3/3] fix: tags => heads --- .github/workflows/docker-build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 767c4ef..3980e0f 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -32,9 +32,9 @@ jobs: - name: Should push? id: shoudPush run: | - if [[ ${{ github.event.ref }} =~ ^refs/tags/php[0-9]dot[0-9]$ ]]; then + if [[ ${{ github.event.ref }} =~ ^refs/heads/php[0-9]dot[0-9]$ ]]; then echo "match=true" >> $GITHUB_OUTPUT - elif [[ ${{ github.event.ref }} = "master" ]]; then + elif [[ ${{ github.event.ref }} = "refs/heads/master" ]]; then echo "match=true" >> $GITHUB_OUTPUT fi