|
8 | 8 | - "*" |
9 | 9 | workflow_dispatch: |
10 | 10 |
|
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
11 | 15 | env: |
12 | 16 | DOCKER_IMAGE: ghcr.io/octoprint/custopizer |
| 17 | + TEST_TAG: testbuild |
13 | 18 |
|
14 | 19 | jobs: |
15 | 20 | build: |
16 | | - name: "Build" |
| 21 | + name: "🏗 Build" |
17 | 22 |
|
18 | 23 | runs-on: ubuntu-latest |
19 | 24 |
|
20 | | - permissions: |
21 | | - contents: read |
22 | | - packages: write |
23 | | - attestations: write |
24 | | - id-token: write |
25 | | - |
26 | 25 | steps: |
27 | 26 | - name: "⬇ Checkout" |
28 | 27 | uses: actions/checkout@v4 |
29 | 28 |
|
30 | | - - name: Docker meta |
31 | | - id: meta |
32 | | - uses: docker/metadata-action@v5 |
33 | | - with: |
34 | | - images: ${{ env.DOCKER_IMAGE }} |
35 | | - tags: | |
36 | | - type=ref,event=branch |
37 | | - type=ref,event=pr |
38 | | - type=semver,pattern={{version}} |
39 | | - type=semver,pattern={{major}}.{{minor}} |
40 | | -
|
41 | 29 | - name: "🐳 Set up Docker Buildx" |
42 | 30 | uses: docker/setup-buildx-action@v3 |
43 | 31 |
|
44 | | - - name: "🐳 Login to GHCR" |
45 | | - uses: docker/login-action@v3 |
46 | | - if: github.event_name != 'pull_request' |
47 | | - with: |
48 | | - registry: ghcr.io |
49 | | - username: ${{ github.repository_owner }} |
50 | | - password: ${{ secrets.GITHUB_TOKEN }} |
51 | | - |
52 | | - - name: "🏗 Build" |
| 32 | + - name: "🏗 Build & push with test tag" |
53 | 33 | id: docker_build |
54 | 34 | uses: docker/build-push-action@v6 |
55 | 35 | with: |
56 | 36 | context: ./src |
57 | 37 | platforms: linux/amd64,linux/arm64 |
58 | | - push: ${{ github.event_name != 'pull_request' }} |
59 | | - tags: ${{ steps.meta.outputs.tags }} |
60 | | - labels: ${{ steps.meta.outputs.labels }} |
| 38 | + tags: "${{ env.DOCKER_IMAGE }}:${{ env.TEST_TAG }}" |
| 39 | + |
| 40 | + test: |
| 41 | + name: "🧪 Test" |
| 42 | + needs: build |
| 43 | + runs-on: "ubuntu-latest" |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Dummy test |
| 47 | + run: | |
| 48 | + echo "A test will run here" |
| 49 | +
|
| 50 | + deploy: |
| 51 | + name: "📦 Deploy" |
| 52 | + needs: test |
| 53 | + runs-on: "ubuntu-latest" |
| 54 | + |
| 55 | + if: github.event_name != 'pull_request' |
| 56 | + |
| 57 | + permissions: |
| 58 | + contents: read |
| 59 | + packages: write |
| 60 | + attestations: write |
| 61 | + id-token: write |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: "🐳 Login to GHCR" |
| 65 | + uses: docker/login-action@v3 |
| 66 | + with: |
| 67 | + registry: ghcr.io |
| 68 | + username: ${{ github.repository_owner }} |
| 69 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + |
| 71 | + - name: 🔍️ Determine metadata |
| 72 | + id: meta |
| 73 | + uses: docker/metadata-action@v5 |
| 74 | + with: |
| 75 | + images: ${{ env.DOCKER_IMAGE }} |
| 76 | + tags: | |
| 77 | + type=ref,event=branch |
| 78 | + type=ref,event=pr |
| 79 | + type=semver,pattern={{version}} |
| 80 | + type=semver,pattern={{major}}.{{minor}} |
| 81 | +
|
| 82 | + - name: 🔖 Push correct tags |
| 83 | + run: | |
| 84 | + TAGS=$(echo "${{ steps.meta.outputs.json }}" | jq -r 'to_entries | map("-e " + .key + "=" + (.value | tostring)) | join(" ")')) |
| 85 | +
|
| 86 | + echo "Would run: docker buildx imagetools create $TAGS $DOCKER_IMAGE:$TEST_TAG" |
| 87 | + |
0 commit comments