Repository navigation
104 lines (93 loc) · 3.3 KB
/
Copy pathdocker-image.yml
File metadata and controls
104 lines (93 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Build & Publish Docker Image
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
pull_request:
paths: ["scripts/hosting_*.py", "scripts/test_hosting_release.py", "scripts/wait_hosting_release.py", ".github/workflows/docker-image.yml"]
env:
REGISTRY: ghcr.io
IMAGE_NAME: opensensor/fief
jobs:
checks:
uses: ./.github/workflows/checks.yml
release-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: python3 -m unittest discover -s scripts -p test_hosting_release.py -v
docker-build-and-push:
if: github.event_name != 'pull_request'
needs: [checks, release-tests]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to GitHub Container Registry
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Build and push Docker image
id: build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
build-args: |
SENTRY_RELEASE=opensensor-fief@${{ github.sha }}
file: docker/Dockerfile.source
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Record this main build's exact platform image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
BUILD_DIGEST: ${{ steps.build.outputs.digest }}
run: python3 scripts/hosting_release_manifest.py
- uses: actions/upload-artifact@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
name: hosting-release-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
path: hosting-release.json
if-no-files-found: error
retention-days: 30
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: docker-build-and-push
runs-on: ubuntu-latest
permissions:
contents: read
statuses: read
timeout-minutes: 40
concurrency:
group: fief-production-verification
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Verify this image is running in production
env:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/wait_hosting_release.py