Merge pull request #1 from opsdev-ws/Dockerfile-adjustments #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Flutter Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/build-push.yml' | |
| workflow_dispatch: | |
| inputs: | |
| flutter_version: | |
| description: 'Flutter version to build (leave empty to use Dockerfile default)' | |
| required: false | |
| type: string | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: opsdev-ws/flutter | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract Flutter version from Dockerfile | |
| id: version | |
| run: | | |
| if [ -n "${{ inputs.flutter_version }}" ]; then | |
| VERSION="${{ inputs.flutter_version }}" | |
| else | |
| VERSION=$(grep -m1 'ARG flutter_ver=' Dockerfile | cut -d'=' -f2) | |
| fi | |
| echo "flutter_version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "Building Flutter version: ${VERSION}" | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=${{ steps.version.outputs.flutter_version }} | |
| type=raw,value=latest | |
| - name: Build and push multi-arch image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| flutter_ver=${{ steps.version.outputs.flutter_version }} |