|
| 1 | +# Experiments: |
| 2 | +# [x] Can I read env.IMAGE_NAME? |
| 3 | +# [x] Can I print git event name? |
| 4 | +# [x] Can I recognize pull requests? |
| 5 | +# [] Can I use if conditions for steps? |
1 | 6 | name: Docker CI
|
2 | 7 |
|
3 | 8 | on:
|
4 | 9 | push:
|
5 |
| - branches: main |
6 |
| - paths: |
7 |
| - - '*.Dockerfile' |
8 |
| - - '*.Dockerfile.dockerignore' |
9 |
| - - '.github/workflows/*.yaml' |
10 |
| - pull_request: |
11 |
| - branches: main |
| 10 | + branches: try-ci-conditionals |
12 | 11 | paths:
|
13 | 12 | - '*.Dockerfile'
|
14 | 13 | - '*.Dockerfile.dockerignore'
|
@@ -42,34 +41,20 @@ jobs:
|
42 | 41 | # https://github.com/docker/metadata-action
|
43 | 42 | - name: Extract Docker metadata
|
44 | 43 | id: meta
|
45 |
| - uses: docker/metadata-action@v5 |
46 |
| - with: |
47 |
| - images: ${{ env.IMAGE_NAME }} |
48 |
| - flavor: latest=true |
| 44 | + if: ${{ github.event_name == 'pull_request' }} |
| 45 | + run: echo 'Extract Docker metadata' |
49 | 46 |
|
50 | 47 | - name: Log into registry ${{ env.REGISTRY }}
|
51 |
| - uses: docker/login-action@v3 |
52 |
| - with: |
53 |
| - registry: ${{ env.REGISTRY }} |
54 |
| - username: ${{ github.actor }} |
55 |
| - password: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + if: ${{ github.event_name == 'pull_request' }} |
| 49 | + run: echo 'Log into registry' |
56 | 50 |
|
57 | 51 | # Build and push Docker image with Buildx (don't push on PR)
|
58 | 52 | # https://github.com/docker/build-push-action
|
59 | 53 | - name: Build and push Docker image
|
60 | 54 | id: build-and-push
|
61 |
| - uses: docker/build-push-action@v6 |
62 |
| - with: |
63 |
| - file: ${{ matrix.purpose }}.Dockerfile |
64 |
| - context: ./plato |
65 |
| - push: ${{ github.event_name != 'pull_request' }} |
66 |
| - tags: ${{ steps.meta.outputs.tags }} |
67 |
| - labels: ${{ steps.meta.outputs.labels }} |
| 55 | + run: echo 'Build and push Docker image' |
68 | 56 |
|
69 | 57 | - name: Check image layers
|
| 58 | + if: ${{ github.event_name == 'pull_request' }} |
70 | 59 | id: check-layers
|
71 |
| - run: | |
72 |
| - set -eux -o pipefail |
73 |
| - docker pull ${{ env.IMAGE_NAME }} |
74 |
| - docker images |
75 |
| - docker image history ${{ env.IMAGE_NAME }} |
| 60 | + run: echo 'Check image layers' |
0 commit comments