|
1 | | -name: DockerX Build (reusable) |
2 | | -on: |
3 | | - workflow_call: |
4 | | - inputs: |
5 | | - dockerfile: |
6 | | - description: "Path to the Dockerfile to build" |
7 | | - required: true |
8 | | - type: string |
9 | | - context: |
10 | | - description: "Logical context identifier (eg: pushi)" |
11 | | - required: true |
12 | | - type: string |
13 | | - platforms: |
14 | | - description: "Comma-separated list of target platforms" |
15 | | - required: true |
16 | | - type: string |
17 | | - tag_suffix: |
18 | | - description: "Suffix appended to the computed base tag (eg: \"-amd64\")" |
19 | | - required: false |
20 | | - type: string |
21 | | - default: "" |
22 | | - secrets: |
23 | | - DOCKERHUB_USERNAME: |
24 | | - required: true |
25 | | - DOCKERHUB_TOKEN: |
26 | | - required: true |
27 | | -jobs: |
28 | | - build: |
29 | | - name: Build |
30 | | - timeout-minutes: 180 |
31 | | - runs-on: [self-hosted, ubuntu, latest] |
32 | | - steps: |
33 | | - - name: Checkout code |
34 | | - uses: actions/checkout@v7 |
35 | | - with: |
36 | | - submodules: true |
37 | | - - name: Set up QEMU |
38 | | - uses: docker/setup-qemu-action@v4 |
39 | | - - name: Set up Docker Buildx |
40 | | - uses: docker/setup-buildx-action@v4 |
41 | | - - name: Login to DockerHub |
42 | | - uses: docker/login-action@v4 |
43 | | - with: |
44 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
45 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
46 | | - - name: Set build variables |
47 | | - id: set_vars |
48 | | - run: | |
49 | | - echo "build_date=$(date +%s)" >> $GITHUB_OUTPUT |
50 | | - if [[ "${{ github.ref_name }}" == "master" ]]; then |
51 | | - base_tag="latest" |
52 | | - else |
53 | | - ref_name=${{ github.ref_name }} |
54 | | - BRANCH_NAME=${ref_name//\//_} |
55 | | - base_tag="$BRANCH_NAME" |
56 | | - fi |
57 | | - echo "tag=${base_tag}${{ inputs.tag_suffix }}" >> $GITHUB_OUTPUT |
58 | | - - name: Build and push |
59 | | - uses: docker/build-push-action@v7 |
60 | | - with: |
61 | | - context: . |
62 | | - file: ${{ inputs.dockerfile }} |
63 | | - platforms: ${{ inputs.platforms }} |
64 | | - push: true |
65 | | - tags: hivesolutions/pushi:${{ steps.set_vars.outputs.tag }} |
66 | | - build-args: | |
67 | | - GIT_COMMIT=${{ github.sha }} |
68 | | - BUILD_DATE=${{ steps.set_vars.outputs.build_date }} |
| 1 | +name: DockerX Build (reusable) |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + dockerfile: |
| 6 | + description: "Path to the Dockerfile to build" |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + context: |
| 10 | + description: "Logical context identifier (eg: pushi)" |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + platforms: |
| 14 | + description: "Comma-separated list of target platforms" |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + tag_suffix: |
| 18 | + description: "Suffix appended to the computed base tag (eg: \"-amd64\")" |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + default: "" |
| 22 | + secrets: |
| 23 | + DOCKERHUB_USERNAME: |
| 24 | + required: true |
| 25 | + DOCKERHUB_TOKEN: |
| 26 | + required: true |
| 27 | +jobs: |
| 28 | + build: |
| 29 | + name: Build |
| 30 | + timeout-minutes: 180 |
| 31 | + runs-on: [self-hosted, ubuntu, latest] |
| 32 | + steps: |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@v7 |
| 35 | + with: |
| 36 | + submodules: true |
| 37 | + - name: Set up QEMU |
| 38 | + uses: docker/setup-qemu-action@v4 |
| 39 | + - name: Set up Docker Buildx |
| 40 | + uses: docker/setup-buildx-action@v4 |
| 41 | + - name: Login to DockerHub |
| 42 | + uses: docker/login-action@v4 |
| 43 | + with: |
| 44 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 45 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 46 | + - name: Set build variables |
| 47 | + id: set_vars |
| 48 | + run: | |
| 49 | + echo "build_date=$(date +%s)" >> $GITHUB_OUTPUT |
| 50 | + if [[ "${{ github.ref_name }}" == "master" ]]; then |
| 51 | + base_tag="latest" |
| 52 | + else |
| 53 | + ref_name=${{ github.ref_name }} |
| 54 | + BRANCH_NAME=${ref_name//\//_} |
| 55 | + base_tag="$BRANCH_NAME" |
| 56 | + fi |
| 57 | + echo "tag=${base_tag}${{ inputs.tag_suffix }}" >> $GITHUB_OUTPUT |
| 58 | + - name: Build and push |
| 59 | + uses: docker/build-push-action@v7 |
| 60 | + with: |
| 61 | + context: . |
| 62 | + file: ${{ inputs.dockerfile }} |
| 63 | + platforms: ${{ inputs.platforms }} |
| 64 | + push: true |
| 65 | + tags: hivesolutions/pushi:${{ steps.set_vars.outputs.tag }} |
| 66 | + build-args: | |
| 67 | + GIT_COMMIT=${{ github.sha }} |
| 68 | + BUILD_DATE=${{ steps.set_vars.outputs.build_date }} |
0 commit comments