Skip to content

Commit f2f0d50

Browse files
committed
Try CI's different conditional on steps
1 parent 65283af commit f2f0d50

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

.github/workflows/docker.yaml

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
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?
16
name: Docker CI
27

38
on:
49
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
1211
paths:
1312
- '*.Dockerfile'
1413
- '*.Dockerfile.dockerignore'
@@ -42,34 +41,20 @@ jobs:
4241
# https://github.com/docker/metadata-action
4342
- name: Extract Docker metadata
4443
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'
4946

5047
- 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'
5650

5751
# Build and push Docker image with Buildx (don't push on PR)
5852
# https://github.com/docker/build-push-action
5953
- name: Build and push Docker image
6054
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'
6856

6957
- name: Check image layers
58+
if: ${{ github.event_name == 'pull_request' }}
7059
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

Comments
 (0)