|
1 |
| -# Build Hermes Docker image, push to Docker Hub and GHCR.io. |
| 1 | +# Build Hermes Docker image, push to GHCR.io. |
2 | 2 |
|
3 | 3 | name: Docker
|
4 | 4 |
|
5 | 5 | on:
|
6 | 6 | workflow_dispatch:
|
7 | 7 | push:
|
8 | 8 | tags:
|
9 |
| - - v[0-9]+.* |
| 9 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 10 | + - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" |
| 11 | + - "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" |
| 12 | + - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - astria |
| 16 | + - upstream-v1.12.0 |
10 | 17 |
|
11 | 18 | env:
|
12 |
| - REGISTRY_IMAGE: informalsystems/hermes |
| 19 | + REGISTRY: ghcr.io |
| 20 | + FULL_REF: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }} |
13 | 21 |
|
14 | 22 | jobs:
|
15 |
| - docker-build: |
| 23 | + build-and-push: |
16 | 24 | runs-on: ubuntu-latest
|
17 |
| - strategy: |
18 |
| - fail-fast: false |
19 |
| - matrix: |
20 |
| - platform: |
21 |
| - - id: linux/amd64 |
22 |
| - name: amd64 |
23 |
| - - id: linux/arm64 |
24 |
| - name: arm64 |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + id-token: write |
| 28 | + packages: write |
25 | 29 | steps:
|
26 |
| - - name: Checkout |
27 |
| - uses: actions/checkout@v4 |
28 |
| - |
29 |
| - - name: Docker meta |
30 |
| - id: meta |
31 |
| - uses: docker/metadata-action@v5 |
| 30 | + # Checking out the repo |
| 31 | + - uses: actions/checkout@v4 |
32 | 32 | with:
|
33 |
| - images: ${{ env.REGISTRY_IMAGE }} |
34 |
| - tags: | |
35 |
| - type=ref,event=tag |
36 |
| - type=ref,event=branch |
37 |
| - type=semver,pattern={{version}} |
38 |
| -
|
39 |
| - - name: Set up QEMU |
40 |
| - uses: docker/setup-qemu-action@v3 |
41 |
| - |
42 |
| - - name: Set up Docker Buildx |
43 |
| - id: buildx |
44 |
| - uses: docker/setup-buildx-action@v3 |
45 |
| - |
| 33 | + ref: ${{ inputs.tag }} |
| 34 | + - uses: depot/setup-action@v1 |
46 | 35 | - name: Login to Docker Hub
|
47 |
| - uses: docker/login-action@v3 |
48 |
| - with: |
49 |
| - username: ${{ secrets.DOCKER_HUB_USERNAME }} |
50 |
| - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
51 |
| - |
52 |
| - - name: Build and push by digest |
53 |
| - id: build |
54 |
| - uses: docker/build-push-action@v6 |
| 36 | + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'astriaorg/hermes' |
| 37 | + uses: docker/login-action@v2 |
55 | 38 | with:
|
56 |
| - context: . |
57 |
| - file: ./ci/release/hermes.Dockerfile |
58 |
| - platforms: ${{ matrix.platform.id }} |
59 |
| - labels: ${{ steps.meta.outputs.labels }} |
60 |
| - outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true |
61 |
| - cache-from: type=gha |
62 |
| - cache-to: type=gha,mode=max |
63 |
| - |
64 |
| - - name: Export digest |
65 |
| - run: | |
66 |
| - mkdir -p /tmp/digests |
67 |
| - digest="${{ steps.build.outputs.digest }}" |
68 |
| - touch "/tmp/digests/${digest#sha256:}" |
69 |
| -
|
70 |
| - - name: Upload digest |
71 |
| - uses: actions/upload-artifact@v4 |
72 |
| - with: |
73 |
| - name: digests-${{ matrix.platform.name }} |
74 |
| - path: /tmp/digests/* |
75 |
| - if-no-files-found: error |
76 |
| - retention-days: 1 |
77 |
| - |
78 |
| - docker-merge: |
79 |
| - runs-on: ubuntu-latest |
80 |
| - needs: |
81 |
| - - docker-build |
82 |
| - steps: |
83 |
| - - name: Download digests |
84 |
| - uses: actions/download-artifact@v4 |
| 39 | + username: ${{ secrets.DOCKER_USER }} |
| 40 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 41 | + - name: Log in to GHCR |
| 42 | + uses: docker/login-action@v2 |
85 | 43 | with:
|
86 |
| - pattern: digests-* |
87 |
| - merge-multiple: true |
88 |
| - path: /tmp/digests |
89 |
| - |
90 |
| - - name: Set up Docker Buildx |
91 |
| - uses: docker/setup-buildx-action@v3 |
92 |
| - |
93 |
| - - name: Docker meta |
94 |
| - id: meta |
95 |
| - uses: docker/metadata-action@v5 |
| 44 | + registry: ${{ env.REGISTRY }} |
| 45 | + username: ${{ github.actor }} |
| 46 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + # Generate correct tabs and labels |
| 48 | + - name: Docker metadata |
| 49 | + id: metadata |
| 50 | + uses: docker/metadata-action@v4 |
96 | 51 | with:
|
97 |
| - images: ${{ env.REGISTRY_IMAGE }} |
| 52 | + images: ghcr.io/astriaorg/hermes |
98 | 53 | tags: |
|
99 |
| - type=ref,event=tag |
100 |
| - type=ref,event=branch |
101 |
| - type=semver,pattern={{version}} |
102 |
| -
|
103 |
| - - name: Login to Docker Hub |
104 |
| - uses: docker/login-action@v3 |
| 54 | + type=ref,event=pr |
| 55 | + type=match,pattern=refs/tags/v(.*),group=1,enable=${{ startsWith(env.FULL_REF, 'refs/tags/') }},value=${{ env.FULL_REF }} |
| 56 | + type=sha |
| 57 | + # set latest tag for `main` branch |
| 58 | + type=raw,value=latest,enable=${{ env.FULL_REF == format('refs/heads/{0}', 'main') }} |
| 59 | + - name: Build and push |
| 60 | + uses: depot/build-push-action@v1 |
105 | 61 | with:
|
106 |
| - username: ${{ secrets.DOCKER_HUB_USERNAME }} |
107 |
| - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
108 |
| - |
109 |
| - - name: Create manifest list and push |
110 |
| - working-directory: /tmp/digests |
111 |
| - run: | |
112 |
| - docker buildx imagetools create --tag ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} \ |
113 |
| - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
114 |
| -
|
115 |
| - - name: Inspect image |
116 |
| - run: | |
117 |
| - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
118 |
| -
|
119 |
| - - name: Login to GitHub Container Registry |
120 |
| - uses: docker/login-action@v3 |
121 |
| - with: |
122 |
| - registry: ghcr.io |
123 |
| - username: ${{ github.repository_owner }} |
124 |
| - password: ${{ secrets.GITHUB_TOKEN }} |
125 |
| - |
126 |
| - - name: Push image to GHCR |
127 |
| - run: | |
128 |
| - docker buildx imagetools create \ |
129 |
| - --tag ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} \ |
130 |
| - ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
| 62 | + # this gets rid of the unknown/unknown image that is created without this setting |
| 63 | + # https://github.com/docker/build-push-action/issues/820#issuecomment-1455687416 |
| 64 | + provenance: false |
| 65 | + context: . |
| 66 | + file: ci/release/hermes.Dockerfile |
| 67 | + platforms: "linux/amd64,linux/arm64" |
| 68 | + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'astriaorg/hermes' }} |
| 69 | + tags: ${{ steps.metadata.outputs.tags }} |
| 70 | + labels: ${{ steps.metadata.outputs.labels }} |
| 71 | + project: qz2p12cbtf |
0 commit comments