|
1 | | -name: Build and Publish Hyperion Docker Images |
2 | | -on: |
3 | | - workflow_dispatch: |
4 | | - push: |
5 | | - tags: |
6 | | - - 'v*.*.*' |
7 | | - |
8 | | -jobs: |
9 | | - docker: |
10 | | - runs-on: ubuntu-latest |
11 | | - timeout-minutes: 10 |
12 | | - |
13 | | - steps: |
14 | | - - name: Check out the code |
15 | | - uses: actions/checkout@v4 |
16 | | - |
17 | | - - name: Docker metadata |
18 | | - id: meta |
19 | | - uses: docker/metadata-action@v5 |
20 | | - with: |
21 | | - images: ${{ secrets.DOCKER_REGISTRY_IDENTIFER }}/hyperion |
22 | | - tags: | |
23 | | - type=semver,pattern={{version}} |
24 | | - type=semver,pattern={{major}}.{{minor}} |
25 | | -
|
26 | | - - name: Set up Docker Buildx |
27 | | - uses: docker/setup-buildx-action@v3 |
28 | | - |
29 | | - - name: Login to GitHub Container Registry |
30 | | - uses: docker/login-action@v3 |
31 | | - with: |
32 | | - registry: ${{ secrets.DOCKER_REGISTRY_URL }} |
33 | | - username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} |
34 | | - password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} |
35 | | - |
36 | | - - name: Build and push app |
37 | | - uses: docker/build-push-action@v6 |
38 | | - with: |
39 | | - context: . |
40 | | - platforms: linux/amd64 #,linux/arm64 |
41 | | - push: true |
42 | | - tags: ${{ steps.meta.outputs.tags }} |
43 | | - labels: ${{ steps.meta.outputs.labels }} |
44 | | - cache-from: type=gha |
45 | | - cache-to: type=gha,mode=max |
| 1 | +name: Build and Publish Hyperion Docker Images |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + docker: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + timeout-minutes: 10 |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Check out the code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Calculate requirements md5 |
| 18 | + run: | |
| 19 | + echo "REQUIREMENTS_MD5=$(cat requirements-common.txt requirements-prod.txt | md5sum | cut -d ' ' -f 1)" >> $GITHUB_ENV |
| 20 | + |
| 21 | + - name: Check if base image exists |
| 22 | + run: | |
| 23 | + HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ |
| 24 | + -u ${{ secrets.DOCKER_REGISTRY_USERNAME }}:${{ secrets.DOCKER_REGISTRY_PASSWORD }} \ |
| 25 | + -H "Accept: application/vnd.oci.image.index.v1+json" \ |
| 26 | + "${{ secrets.DOCKER_REGISTRY_URL }}/v2/hyperion-base/manifests/${{ env.REQUIREMENTS_MD5 }}") |
| 27 | + |
| 28 | + echo "HTTP_CODE=$HTTP_CODE" >> $GITHUB_ENV |
| 29 | + |
| 30 | + if [ "$HTTP_CODE" -ne 200 ]; then |
| 31 | + echo "Error: Base image not found, wait for the base image to be built first" |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | + |
| 35 | + echo "EXISTS=true" >> $GITHUB_ENV |
| 36 | + |
| 37 | + - name: Docker metadata |
| 38 | + if: env.EXISTS == 'true' |
| 39 | + id: meta |
| 40 | + uses: docker/metadata-action@v5 |
| 41 | + with: |
| 42 | + images: ${{ secrets.DOCKER_REGISTRY_IDENTIFER }}/hyperion |
| 43 | + tags: | |
| 44 | + type=semver,pattern={{version}} |
| 45 | + type=semver,pattern={{major}}.{{minor}} |
| 46 | +
|
| 47 | + - name: Set up Docker Buildx |
| 48 | + if: env.EXISTS == 'true' |
| 49 | + uses: docker/setup-buildx-action@v3 |
| 50 | + |
| 51 | + - name: Login to GitHub Container Registry |
| 52 | + if: env.EXISTS == 'true' |
| 53 | + uses: docker/login-action@v3 |
| 54 | + with: |
| 55 | + registry: ${{ secrets.DOCKER_REGISTRY_URL }} |
| 56 | + username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} |
| 57 | + password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} |
| 58 | + |
| 59 | + - name: Build and push app |
| 60 | + if: env.EXISTS == 'true' |
| 61 | + uses: docker/build-push-action@v6 |
| 62 | + with: |
| 63 | + context: . |
| 64 | + platforms: linux/amd64 #,linux/arm64 |
| 65 | + push: true |
| 66 | + tags: ${{ steps.meta.outputs.tags }} |
| 67 | + labels: ${{ steps.meta.outputs.labels }} |
| 68 | + cache-from: type=gha |
| 69 | + cache-to: type=gha,mode=max |
| 70 | + build-args: | |
| 71 | + REQUIREMENTS_MD5=${{env.REQUIREMENTS_MD5}} |
| 72 | + DOCKER_REGISTRY_IDENTIFER=${{ secrets.DOCKER_REGISTRY_IDENTIFER }} |
0 commit comments