|
| 1 | +name: Build & Deploy Docker Containers |
| 2 | +on: |
| 3 | + # Build on push to any branch |
| 4 | + push: [] |
| 5 | + |
| 6 | +jobs: |
| 7 | + deploy-images: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + strategy: |
| 10 | + fail-fast: false |
| 11 | + # Just build primary Dockerfile, tag, arm and amd64 for now |
| 12 | + matrix: |
| 13 | + dockerfile: [[Dockerfile, linux/amd64, '']] |
| 14 | + |
| 15 | + name: Build ${{ matrix.dockerfile[0] }} |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v3 |
| 19 | + |
| 20 | + - name: Set Container Tag |
| 21 | + run: | |
| 22 | + branch=$(echo ${GITHUB_REF##*/}) |
| 23 | + printf "Branch is ${branch}\n" |
| 24 | + tagged="quay.io/singularity/docker2singularity:${branch}${{ matrix.dockerfile[2] }}" |
| 25 | + if [[ "${branch}" == "master" ]]; then |
| 26 | + container="quay.io/singularity/docker2singularity:latest${{ matrix.dockerfile[2] }}" |
| 27 | + else |
| 28 | + container=${tagged} |
| 29 | + fi |
| 30 | + echo "container=${container}" >> $GITHUB_ENV |
| 31 | + echo "branch=${branch}" >> $GITHUB_ENV |
| 32 | + echo "tagged=${tagged}" >> $GITHUB_ENV |
| 33 | +
|
| 34 | + - name: Log in to Quay Container Registry |
| 35 | + if: github.event_name == 'push' |
| 36 | + uses: docker/login-action@v2 |
| 37 | + with: |
| 38 | + registry: quay.io |
| 39 | + username: ${{ secrets.DOCKER_USER }} |
| 40 | + password: ${{ secrets.DOCKER_PASS }} |
| 41 | + |
| 42 | + - name: Set up QEMU |
| 43 | + uses: docker/setup-qemu-action@v2 |
| 44 | + |
| 45 | + - name: Set up Docker Buildx |
| 46 | + uses: docker/setup-buildx-action@v2 |
| 47 | + |
| 48 | + - name: Inspect Container Names |
| 49 | + run: | |
| 50 | + printf "Tagged: ${tagged}\n" |
| 51 | + printf "Container: ${container}\n" |
| 52 | +
|
| 53 | + - name: Build |
| 54 | + uses: docker/build-push-action@v3 |
| 55 | + if: github.event_name != 'push' |
| 56 | + with: |
| 57 | + file: ${{matrix.dockerfile[0]}} |
| 58 | + platforms: ${{ matrix.dockerfile[1] }} |
| 59 | + push: false |
| 60 | + tags: | |
| 61 | + ${{ env.container }} |
| 62 | + ${{ env.tagged }} |
| 63 | +
|
| 64 | + - name: Build & Deploy |
| 65 | + uses: docker/build-push-action@v3 |
| 66 | + if: github.event_name == 'push' |
| 67 | + with: |
| 68 | + file: ${{matrix.dockerfile[0]}} |
| 69 | + platforms: ${{ matrix.dockerfile[1] }} |
| 70 | + push: true |
| 71 | + tags: | |
| 72 | + ${{ env.container }} |
| 73 | + ${{ env.tagged }} |
0 commit comments