Merge pull request #707 from GaikwadPratik/multi-arch-image #91
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: Docker Image CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [master] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name : Build and push multi-arch DVWA image | |
| run: | | |
| IMAGE_ID=ghcr.io/${{ github.repository_owner }}/dvwa | |
| IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
| VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
| [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
| [ "$VERSION" == "master" ] && VERSION=latest | |
| COMMIT=$(echo "${{ github.sha }}" | cut -c 1-7) | |
| echo IMAGE_ID=$IMAGE_ID | |
| echo VERSION=$VERSION | |
| echo COMMIT=$COMMIT | |
| docker buildx build --platform linux/amd64,linux/arm64 \ | |
| --tag $IMAGE_ID:$VERSION \ | |
| --tag $IMAGE_ID:$COMMIT \ | |
| --push . | |