Skip to content

Commit 080ca4d

Browse files
committed
[#73] Upload seed.sh to release assets.
1 parent 48e3c7f commit 080ca4d

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,9 @@ jobs:
6969
tags: ${{ steps.meta.outputs.tags }}
7070
labels: ${{ steps.meta.outputs.labels }}
7171
platforms: linux/amd64,linux/arm64
72+
73+
- name: Upload seed.sh to release
74+
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2
75+
with:
76+
files: seed.sh
77+
overwrite: true

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ BUILDX_PLATFORMS=linux/arm64 DOCKER_DEFAULT_PLATFORM=linux/arm64 tests/bats/node
109109
- Pushes `canary` tag to DockerHub on main branch
110110

111111
**release.yml** - Runs on Git tags:
112-
- Drafts release notes using release-drafter
112+
- Drafts release notes using release-drafter with CalVer version
113113
- Builds and pushes versioned + `latest` tags to DockerHub
114+
- Uploads `seed.sh` as a release asset
114115

115116
### Configuration
116117

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ Versions are following versions of the [upstream image](https://hub.docker.com/r
101101

102102
Releases are scheduled to occur at a minimum of once per month.
103103

104-
This image is built by DockerHub via an automated build and tagged as follows:
104+
This image is built by GitHub Actions and tagged as follows:
105105

106106
- `YY.m.patch` tag - when release tag is published on GitHub.
107107
- `latest` - when release tag is published on GitHub.
108108
- `canary` - on every push to `main` branch
109109

110+
The `seed.sh` script is automatically uploaded as a release asset and can be downloaded from the latest release.
111+
110112
### Dependencies update
111113

112114
Renovate bot is used to update dependencies. It creates a PR with the changes

seed.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22
##
3-
# Seed image with a database from file.
3+
# Seed image with a database from a file.
44
# @see https://github.com/drevops/mariadb-drupal-data/blob/main/seed.sh
55
#
6-
# The seeding process has 3-phases:
6+
# The seeding process has 3 phases:
77
# 1. Create extracted DB files by starting a temporary container and importing the database.
88
# 2. Build a new image from the base image and extracted DB files.
99
# 3. Start a container from the new image and verify that the database was imported.
@@ -18,10 +18,10 @@
1818
set -eu
1919
[ -n "${DEBUG:-}" ] && set -x
2020

21-
# Database dump file as a first argument to the script.
21+
# Database dump file as the first argument to the script.
2222
DB_FILE="${DB_FILE:-$1}"
2323

24-
# Destination image as a second argument to the script.
24+
# Destination image as the second argument to the script.
2525
DST_IMAGE="${DST_IMAGE:-$2}"
2626

2727
# Base image to start with.
@@ -30,7 +30,7 @@ DST_IMAGE="${DST_IMAGE:-$2}"
3030
BASE_IMAGE="${BASE_IMAGE:-drevops/mariadb-drupal-data:latest}"
3131

3232
# Docker target platform architecture.
33-
# Note that some shells report platform incorrectly. In such cases, run
33+
# Note that some shells report the platform incorrectly. In such cases, run
3434
# as `DOCKER_DEFAULT_PLATFORM=linux/amd64 ./seed.sh path/to/db.sql myorg/myimage:latest`
3535
DOCKER_DEFAULT_PLATFORM="${DOCKER_DEFAULT_PLATFORM:-}"
3636

@@ -56,8 +56,8 @@ fail() { [ -z "${TERM_NO_COLOR:-}" ] && tput colors >/dev/null 2>&1 && printf "\
5656
note() { printf " %s\n" "$1"; }
5757
# @formatter:on
5858

59-
[ -z "${DB_FILE}" ] && fail "Path to the database dump file must be provided as a first argument." && exit 1
60-
[ -z "${DST_IMAGE}" ] && fail "Destination docker image name must be provided as a second argument." && exit 1
59+
[ -z "${DB_FILE}" ] && fail "Path to the database dump file must be provided as the first argument." && exit 1
60+
[ -z "${DST_IMAGE}" ] && fail "Destination Docker image name must be provided as the second argument." && exit 1
6161
[ ! -f "${DB_FILE}" ] && fail "Specified database dump file ${DB_FILE} does not exist." && exit 1
6262
[ "${BASE_IMAGE##*/}" = "$BASE_IMAGE" ] && fail "${BASE_IMAGE} should be in a format myorg/myimage." && exit 1
6363
[ "${DST_IMAGE##*/}" = "$DST_IMAGE" ] && fail "${DST_IMAGE} should be in a format myorg/myimage." && exit 1
@@ -114,12 +114,12 @@ wait_for_db_service() {
114114

115115
echo -n " Waiting for the service to become ready."
116116
if ! docker exec "${user[@]}" -i "${cid}" sh -c "until nc -z localhost 3306; do sleep 1; echo -n .; done; echo"; then
117-
fail "MYSQL service did not start successfully."
117+
fail "MySQL service did not start successfully."
118118
log_container "${cid}"
119119
return 1
120120
fi
121121
log_container "${cid}"
122-
pass "MYSQL is running."
122+
pass "MySQL is running."
123123
}
124124

125125
assert_db_system_tables_present() {
@@ -191,7 +191,7 @@ if [ -n "${DOCKER_DEFAULT_PLATFORM}" ]; then
191191
task "Source platform architecture: ${DOCKER_DEFAULT_PLATFORM}"
192192
fi
193193

194-
# Normalise image - add ":latest" if tag was not provided.
194+
# Normalize image - add ":latest" if tag was not provided.
195195
[ -n "${DST_IMAGE##*:*}" ] && DST_IMAGE="${DST_IMAGE}:latest"
196196
note "Destination image: ${DST_IMAGE}"
197197
note "Destination platform(s): ${DESTINATION_PLATFORMS}"
@@ -234,7 +234,7 @@ pass "Updated permissions on the seeded database files."
234234
task "Copy expanded database files to host"
235235
mkdir -p "${TMP_STRUCTURE_DIR}"
236236
docker cp "${cid}":/home/db-data/. "${TMP_STRUCTURE_DIR}/" >/dev/null
237-
[ ! -d "${TMP_STRUCTURE_DIR}/mysql" ] && fail "Unable to copy expanded database files to host " && ls -al "${TMP_STRUCTURE_DIR}" && exit 1
237+
[ ! -d "${TMP_STRUCTURE_DIR}/mysql" ] && fail "Unable to copy expanded database files to host" && ls -al "${TMP_STRUCTURE_DIR}" && exit 1
238238
pass "Copied expanded database files to host"
239239

240240
stop_container "${cid}"

0 commit comments

Comments
 (0)