|
1 | 1 | name: Multi-Arch Docker Build and Push to GHCR |
2 | | - |
3 | 2 | on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v* |
4 | 6 | workflow_dispatch: |
5 | | - inputs: |
6 | | - branches: |
7 | | - description: "branch" |
8 | | - type: string |
9 | | - default: master |
10 | | - tags: |
11 | | - description: "tag" |
12 | | - type: string |
13 | | - default: v0.1.0 |
14 | | - |
15 | 7 |
|
16 | 8 | jobs: |
17 | 9 | build: |
18 | 10 | runs-on: ubuntu-latest |
19 | | - |
20 | 11 | steps: |
21 | | - - name: Checkout code |
22 | | - uses: actions/checkout@v2 |
23 | | - |
24 | | - - name: Login to GHCR |
25 | | - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin |
26 | | - |
27 | | - - name: Set up QEMU |
28 | | - uses: docker/setup-qemu-action@v3 |
29 | | - |
30 | | - - name: Set up Docker Buildx for multiarch images |
31 | | - uses: docker/setup-buildx-action@v3 |
32 | | - |
33 | | - - name: Build and push Docker image to GHCR |
34 | | - run: | |
35 | | - # Strip git ref prefix from version |
36 | | - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') |
37 | | -
|
38 | | - # Strip "v" prefix from tag name |
39 | | - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') |
40 | | -
|
41 | | - docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 \ |
42 | | - --push \ |
43 | | - -t ghcr.io/${{ github.repository }}:${VERSION} \ |
44 | | - . |
| 12 | + - name: Check out the repository |
| 13 | + uses: actions/checkout@v3 |
| 14 | + |
| 15 | + - name: Login to GitHub Container Registry |
| 16 | + uses: docker/login-action@v2 |
| 17 | + with: |
| 18 | + registry: ghcr.io |
| 19 | + username: ${{ github.actor }} |
| 20 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + |
| 22 | + - name: Calculate metadata for image |
| 23 | + id: image-meta |
| 24 | + uses: docker/metadata-action@v4 |
| 25 | + with: |
| 26 | + images: ghcr.io/stackhpc/radosgw_usage_exporter |
| 27 | + # Produce the branch name or tag and the SHA as tags |
| 28 | + tags: | |
| 29 | + type=ref,event=branch |
| 30 | + type=ref,event=tag |
| 31 | + type=sha,prefix= |
| 32 | +
|
| 33 | + - name: Build and push image |
| 34 | + uses: stackhpc/github-actions/docker-multiarch-build-push@master |
| 35 | + with: |
| 36 | + cache-key: radosgw_usage_exporter |
| 37 | + context: . |
| 38 | + platforms: linux/amd64,linux/arm64 |
| 39 | + push: true |
| 40 | + tags: ${{ steps.image-meta.outputs.tags }} |
| 41 | + labels: ${{ steps.image-meta.outputs.labels }} |
0 commit comments