|
| 1 | +--- |
| 2 | + |
| 3 | +on: # yamllint disable-line rule:truthy |
| 4 | + release: |
| 5 | + types: |
| 6 | + - released |
| 7 | + |
| 8 | +name: 🚀 Build docker images with release tag |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: "ubuntu-latest" |
| 13 | + strategy: |
| 14 | + fail-fast: true |
| 15 | + matrix: |
| 16 | + os_name: ["alpine"] |
| 17 | + php_version: [ "8.1" ] |
| 18 | + php_type: [ "fpm" ] |
| 19 | + # php_version: ["8.1", "8.2"] |
| 20 | + # php_type: ["fpm", "cli", "supervisord"] |
| 21 | + environment: |
| 22 | + name: release |
| 23 | + url: https://hub.docker.com/r/wayofdev/php-base/tags?page=1 |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: 📦 Check out the codebase |
| 27 | + uses: actions/checkout@v3 |
| 28 | + |
| 29 | + - name: 🛠️ Install goss and dgoss |
| 30 | + |
| 31 | + |
| 32 | + - name: 🌎 Set environment variables |
| 33 | + env: |
| 34 | + IMAGE_NAMESPACE: wayofdev/php-base |
| 35 | + IMAGE_TEMPLATE: ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }} |
| 36 | + IMAGE_TAG: wayofdev/php-base:${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ env.VERSION }} |
| 37 | + run: | |
| 38 | + export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \ |
| 39 | + && { \ |
| 40 | + echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \ |
| 41 | + echo "IMAGE_TEMPLATE=${IMAGE_TEMPLATE}"; \ |
| 42 | + echo "VERSION=${RELEASE_VERSION:1}"; \ |
| 43 | + } >> "$GITHUB_ENV" |
| 44 | +
|
| 45 | + - name: 🤖 Generate dist files |
| 46 | + run: make generate |
| 47 | + |
| 48 | + - name: 🐳 Extract docker meta data |
| 49 | + id: meta |
| 50 | + uses: docker/metadata-action@v4 |
| 51 | + with: |
| 52 | + images: ${{ env.IMAGE_NAMESPACE }} |
| 53 | + tags: | |
| 54 | + type=raw,event=branch,value=latest |
| 55 | + type=ref,event=pr |
| 56 | + type=semver,pattern={{version}} |
| 57 | + type=semver,pattern={{major}}.{{minor}} |
| 58 | + flavor: | |
| 59 | + latest=false |
| 60 | + prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}- |
| 61 | +
|
| 62 | + - name: 🔑 Login to docker-hub |
| 63 | + if: github.event_name != 'pull_request' |
| 64 | + uses: docker/login-action@v2 |
| 65 | + with: |
| 66 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 67 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 68 | + |
| 69 | + - name: 🖥️ Setup QEMU |
| 70 | + uses: docker/setup-qemu-action@v2 |
| 71 | + with: |
| 72 | + platforms: arm64 |
| 73 | + |
| 74 | + - name: 🛠️ Setup docker Buildx |
| 75 | + uses: docker/setup-buildx-action@v2 |
| 76 | + with: |
| 77 | + install: true |
| 78 | + |
| 79 | + - name: 🚀 Build image and push to docker-hub |
| 80 | + uses: docker/build-push-action@v4 |
| 81 | + with: |
| 82 | + context: ./dist/base/${{ env.IMAGE_TEMPLATE }} |
| 83 | + platforms: linux/amd64,linux/arm64 |
| 84 | + push: ${{ github.event_name != 'pull_request' }} |
| 85 | + tags: ${{ steps.meta.outputs.tags }} |
| 86 | + cache-from: type=gha |
| 87 | + cache-to: type=gha,mode=max |
| 88 | + labels: ${{ steps.meta.outputs.labels }} |
| 89 | + |
| 90 | + - name: 🧪 Test Docker image with "version" tag |
| 91 | + run: IMAGE_TAG=${{ env.IMAGE_TAG }} make test |
| 92 | + |
| 93 | +... |
0 commit comments