diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3a902c04..277828fd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,7 +1,11 @@ name: CI build of all containers on: - - push - - pull_request + push: + branches: + - main + tags: + - "*" + pull_request: jobs: push: @@ -14,25 +18,9 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Build hinfo image - run: | - docker build . \ - -f Dockerfile.hinfo \ - --tag consdb-hinfo \ - --label "runnumber=${GITHUB_RUN_ID}" - - - name: Log in to GitHub Container Registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: Push image - run: | - ID=ghcr.io/${{ github.repository_owner }}/consdb-hinfo - if [[ "${{ github.ref }}" == "refs/pull/"* ]]; then - VERSION=$(echo "${{ github.head_ref }}" | sed -e 's|.*/||') - elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then - VERSION=$(echo "${{ github.ref_name }}" | sed -e 's|^v||') - else - VERSION=latest - fi - docker tag consdb-hinfo $ID:$VERSION - docker push $ID:$VERSION + - name: Build hinfo + uses: lsst-sqre/build-and-push-to-ghcr@v1 + with: + image: ${{ github.repository_owner }}/consdb-hinfo + github_token: ${{ secrets.GITHUB_TOKEN }} + dockerfile: Dockerfile.hinfo