summaryrefslogtreecommitdiff
path: root/.github/workflows/image.yaml
blob: 5b8e14e98957e6125249cc2487910625b8f30030 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Build and push image

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
    types: [ labeled, unlabeled, opened, synchronize, reopened ]

jobs:
  build_image:
    if: github.repository == 'argoproj-labs/argocd-image-updater'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          path: argocd-image-updater
      - name: Setup qemu
        uses: docker/setup-qemu-action@v1
      - name: Setup Docker buildx
        uses: docker/setup-buildx-action@v1
      - name: Build and possibly push image
        run: |
          set -ex
          MULTIARCH=no
          PUSH=no
          if [[ "${{ github.event_name }}" == "push" ]]; then
            MULTIARCH=yes
            PUSH=yes
          elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'test-arm-image') }}" == "true" ]]; then
            MULTIARCH=yes
          fi
          if [[ "${PUSH}" == "yes" ]]; then
            docker login --username "${DOCKER_USERNAME}" --password "${DOCKER_TOKEN}" quay.io
          fi
          if [[ "${MULTIARCH}" = "yes" ]]; then
            IMAGE_PUSH=${PUSH} make multiarch-image
          else
            make image
          fi
        working-directory: argocd-image-updater
        env:
          DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.QUAY_TOKEN }}