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