|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + types: [opened, synchronize] |
| 8 | + paths-ignore: |
| 9 | + - '**/*.md' |
| 10 | + push: |
| 11 | + # Build for the master branch. |
| 12 | + branches: |
| 13 | + - master |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + ref: |
| 17 | + description: 'Ref to build the binary [default: latest master; examples: v0.10.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]' |
| 18 | + required: false |
| 19 | + default: '' |
| 20 | + push_image: |
| 21 | + description: 'Push images to DockerHub [default: false; examples: true, false]' |
| 22 | + required: false |
| 23 | + default: 'false' |
| 24 | + use_latest_tag: |
| 25 | + description: 'Use `latest` tag while pushing images to DockerHub [default: false; examples: true, false]' |
| 26 | + required: false |
| 27 | + default: 'false' |
| 28 | + |
| 29 | +jobs: |
| 30 | + build_image: |
| 31 | + name: Build Docker image |
| 32 | + runs-on: ubuntu-22.04 |
| 33 | + |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + ref: ${{ github.event.inputs.ref }} |
| 38 | + fetch-depth: 0 |
| 39 | + |
| 40 | + - name: Set up QEMU |
| 41 | + uses: docker/setup-qemu-action@v3 |
| 42 | + |
| 43 | + - name: Set up Docker Buildx |
| 44 | + uses: docker/setup-buildx-action@v3 |
| 45 | + |
| 46 | + - name: Login to DockerHub |
| 47 | + if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }} |
| 48 | + uses: docker/login-action@v3 |
| 49 | + with: |
| 50 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 51 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 52 | + |
| 53 | + - name: Set version |
| 54 | + id: setver |
| 55 | + run: cat .env >> $GITHUB_OUTPUT |
| 56 | + |
| 57 | + - name: Set latest tag |
| 58 | + id: setlatest |
| 59 | + if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.use_latest_tag == 'true') }} |
| 60 | + run: echo "latest=,nspccdev/neofs-rest-gw:latest" >> $GITHUB_OUTPUT |
| 61 | + |
| 62 | + - name: Build and push image |
| 63 | + uses: docker/build-push-action@v5 |
| 64 | + with: |
| 65 | + context: . |
| 66 | + file: Dockerfile |
| 67 | + push: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }} |
| 68 | + platforms: linux/amd64 |
| 69 | + build-args: | |
| 70 | + NEOGO_HUB_IMAGE=nspccdev/neo-go |
| 71 | + NEOGO_HUB_TAG=${{ steps.setver.outputs.NEOGO_VERSION }} |
| 72 | + NEOFS_HUB_IMAGE=nspccdev/neofs |
| 73 | + NEOFS_HUB_TAG=${{ steps.setver.outputs.AIO_VERSION }} |
| 74 | + NEOFS_HTTP_HUB_TAG=${{ steps.setver.outputs.HTTPGW_VERSION }} |
| 75 | + NEOFS_REST_HUB_TAG=${{ steps.setver.outputs.RESTGW_VERSION }} |
| 76 | + tags: nspccdev/neofs-aio:${{ steps.setver.outputs.AIO_VERSION }}${{ steps.setlatest.outputs.latest }} |
0 commit comments