Skip to content

Commit d2d70ff

Browse files
committed
Update CI to deduplicate steps (don't build and push twice per version) and if on main, push to Docker Hub
1 parent 6164bcf commit d2d70ff

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

.github/workflows/continuous-integration-workflow.yml

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
name: Build and Test
2-
3-
on:
4-
[push, pull_request]
5-
1+
name: CI
2+
on: push
63
jobs:
74
ci:
85
runs-on: ubuntu-latest
@@ -91,3 +88,16 @@ jobs:
9188
env:
9289
CI_VERSION: ${{ matrix.version }}
9390
SKIP_CLEANUP: 1
91+
92+
- name: Login to Docker Hub
93+
if: ${{ github.ref == 'refs/heads/main' }}
94+
uses: docker/login-action@v3
95+
with:
96+
username: ${{ vars.DOCKER_HUB_USERNAME }}
97+
password: ${{ secrets.DOCKER_HUB_PERSONAL_ACCESS_TOKEN }}
98+
99+
- name: Push Docker image
100+
if: ${{ github.ref == 'refs/heads/main' }}
101+
run: ./push.sh
102+
env:
103+
CI_VERSION: ${{ matrix.version }}

build.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ source ./versions.sh
66
build_cmd() {
77
docker build --build-arg "METEOR_VERSION=$1" --tag geoffreybooth/meteor-base:"$1" ./src
88
if [[ $1 == $latest_version ]]; then
9-
docker tag geoffreybooth/meteor-base:"$1" geoffreybooth/meteor-base:latest
9+
if ! docker tag geoffreybooth/meteor-base:"$1" geoffreybooth/meteor-base:latest; then
10+
printf "${RED}Error tagging Docker base image for Meteor (latest version)${NC}\n"
11+
exit 1
12+
fi
1013
fi
1114
}
1215

@@ -26,7 +29,12 @@ done
2629

2730

2831
if [[ "${#versions[@]}" -eq 1 ]]; then
29-
printf "${GREEN}Success building Docker base image for Meteor ${versions}\n"
32+
printf "${GREEN}Success building Docker base image for Meteor ${versions}"
33+
if [[ "${versions[0]}" == $latest_version ]]; then
34+
printf " (latest version)\n"
35+
else
36+
printf "\n"
37+
fi
3038
else
3139
printf "${GREEN}Success building Docker base images for all supported Meteor versions\n"
3240
fi

0 commit comments

Comments
 (0)