From 1b2a6779335b9423ee8dafbba4a4292d9b1e6992 Mon Sep 17 00:00:00 2001 From: lotyp Date: Tue, 16 May 2023 17:53:34 +0300 Subject: [PATCH] feat: move to reusable workflow --- .github/workflows/build-latest.yml | 84 ++++---------------------- .github/workflows/build-release.yml | 93 ----------------------------- 2 files changed, 12 insertions(+), 165 deletions(-) delete mode 100644 .github/workflows/build-release.yml diff --git a/.github/workflows/build-latest.yml b/.github/workflows/build-latest.yml index e77c0ad..da45e27 100644 --- a/.github/workflows/build-latest.yml +++ b/.github/workflows/build-latest.yml @@ -18,77 +18,17 @@ jobs: fail-fast: true matrix: os_name: ["alpine"] - php_version: ["8.1"] - php_type: ["fpm"] - # php_version: ["8.1", "8.2"] - # php_type: ["fpm", "cli", "supervisord"] - environment: - name: latest - url: https://hub.docker.com/r/wayofdev/php-base/tags?page=1&name=latest - - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v3 - - - name: ๐Ÿ› ๏ธ Install goss and dgoss - uses: e1himself/goss-installation-action@v1.1.0 - - - name: ๐ŸŒŽ Set environment variables - env: - IMAGE_NAMESPACE: wayofdev/php-base - IMAGE_TEMPLATE: ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }} - IMAGE_TAG: wayofdev/php-base:${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-latest - run: | - echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}" >> $GITHUB_ENV - echo "IMAGE_TEMPLATE=${IMAGE_TEMPLATE}" >> $GITHUB_ENV - echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV - - - name: ๐Ÿค– Generate dist files - run: make generate - - - name: ๐Ÿณ Extract docker meta data - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.IMAGE_NAMESPACE }} - tags: | - type=raw,event=branch,value=latest - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - flavor: | - latest=false - prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}- - - - name: ๐Ÿ”‘ Login to docker-hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - - name: ๐Ÿ–ฅ๏ธ Setup QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - - name: ๐Ÿ› ๏ธ Setup docker Buildx - uses: docker/setup-buildx-action@v2 - with: - install: true - - - name: ๐Ÿš€ Build image and push to docker-hub - uses: docker/build-push-action@v4 - with: - context: ./dist/base/${{ env.IMAGE_TEMPLATE }} - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max - labels: ${{ steps.meta.outputs.labels }} - - - name: ๐Ÿงช Test Docker image with "latest" tag - run: IMAGE_TAG=${{ env.IMAGE_TAG }} make test + php_version: ["8.1", "8.2"] + php_type: ["fpm", "cli", "supervisord"] + uses: wayofdev/gh-actions/.github/workflows/build-image.yml@master + with: + os: "ubuntu-latest" + push-to-hub: ${{ github.event_name != 'pull_request' }} + image-namespace: "wayofdev/php-base" + image-template: ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }} + image-version: latest + secrets: + docker-username: ${{ secrets.DOCKER_USERNAME }} + docker-password: ${{ secrets.DOCKER_TOKEN }} ... diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml deleted file mode 100644 index 588dd5a..0000000 --- a/.github/workflows/build-release.yml +++ /dev/null @@ -1,93 +0,0 @@ ---- - -on: # yamllint disable-line rule:truthy - release: - types: - - released - -name: ๐Ÿš€ Build docker images with release tag - -jobs: - build: - runs-on: "ubuntu-latest" - strategy: - fail-fast: true - matrix: - os_name: ["alpine"] - php_version: [ "8.1" ] - php_type: [ "fpm" ] - # php_version: ["8.1", "8.2"] - # php_type: ["fpm", "cli", "supervisord"] - environment: - name: release - url: https://hub.docker.com/r/wayofdev/php-base/tags?page=1 - - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v3 - - - name: ๐Ÿ› ๏ธ Install goss and dgoss - uses: e1himself/goss-installation-action@v1.1.0 - - - name: ๐ŸŒŽ Set environment variables - env: - IMAGE_NAMESPACE: wayofdev/php-base - IMAGE_TEMPLATE: ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }} - IMAGE_TAG: wayofdev/php-base:${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ env.VERSION }} - run: | - export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \ - && { \ - echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \ - echo "IMAGE_TEMPLATE=${IMAGE_TEMPLATE}"; \ - echo "VERSION=${RELEASE_VERSION:1}"; \ - } >> "$GITHUB_ENV" - - - name: ๐Ÿค– Generate dist files - run: make generate - - - name: ๐Ÿณ Extract docker meta data - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.IMAGE_NAMESPACE }} - tags: | - type=raw,event=branch,value=latest - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - flavor: | - latest=false - prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}- - - - name: ๐Ÿ”‘ Login to docker-hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - - name: ๐Ÿ–ฅ๏ธ Setup QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - - name: ๐Ÿ› ๏ธ Setup docker Buildx - uses: docker/setup-buildx-action@v2 - with: - install: true - - - name: ๐Ÿš€ Build image and push to docker-hub - uses: docker/build-push-action@v4 - with: - context: ./dist/base/${{ env.IMAGE_TEMPLATE }} - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max - labels: ${{ steps.meta.outputs.labels }} - - - name: ๐Ÿงช Test Docker image with "version" tag - run: IMAGE_TAG=${{ env.IMAGE_TAG }} make test - -...