|
1 | 1 | services: |
2 | 2 | # This service bumps the WordPress verion in the Dockerfile to the latest release. |
| 3 | + # See the bin/bump-wordpress.sh script for docs |
3 | 4 | # |
4 | | - # The shell script does three things: |
5 | | - # |
6 | | - # 1. Fetch the list of stable WordPress versions from the wordpress.org API |
7 | | - # and store it in wp-version.json. The file is just something like this: |
8 | | - # { "wordpress": "5.9.2" } |
9 | | - # 2. Update the WordPress base image in the Dockerfile. |
10 | | - # 3. Update the WordPress version in README.md. |
11 | | - # |
12 | | - # It also defines a few styling vars and echoes progress. |
13 | | - # |
14 | | - # The wp-version.json file should be commited to Git. The push-to-dockerhub |
15 | | - # GitHub Action uses this file to generate tag names for the Docker Image. |
16 | | - # |
17 | | - # Notes: The jq image runs busybox, so sed uses a different flag for Extended Regex |
18 | | - # Docker images names are not validated, it's possible the image hasn't |
19 | | - # been created yet. |
20 | | - # |
21 | | - # https://hub.docker.com/r/realguess/jq |
| 5 | + # https://hub.docker.com/r/jetbrainsinfra/jq |
22 | 6 | bump-wp: |
23 | | - image: realguess/jq:1.4 |
| 7 | + image: jetbrainsinfra/jq:latest |
24 | 8 | volumes: |
25 | 9 | - ./:/app |
26 | 10 | command: | |
27 | | - sh -c " RESET=\"\\033[0m\" RED=\"\\033[31m\" GOLD=\"\\033[33m\" CYAN=\"\\033[36m\" |
28 | | - echo -e \"💫 Fetching releases from the $${CYAN}WordPress API$${RESET}.\" && |
29 | | - wget -q -O- http://api.wordpress.org/core/stable-check/1.0 > /tmp/wp.json && |
30 | | - echo -e \"👀 Found $${CYAN}$$(jq -r 'length' /tmp/wp.json)$${RESET} releases.\" && |
31 | | - jq '{wordpress: (to_entries[] | select(.value == \"latest\").key)}' /tmp/wp.json > /app/wp-version.json && |
32 | | - WP_LATEST=$$(jq -r '.wordpress' /app/wp-version.json) && |
33 | | - echo -e \"✏️ Updating $${GOLD}Dockerfile$${RESET} to $${CYAN}v$$(jq -r '.wordpress' /app/wp-version.json)$${RESET}.\" && |
34 | | - sed -i \"s/wordpress:.*-php8/wordpress:$${WP_LATEST}-php8/\" /app/Dockerfile && |
35 | | - echo -e \"✏️ Updating $${GOLD}README.md$${RESET} to $${CYAN}v$$(jq -r '.wordpress' /app/wp-version.json)$${RESET}.\" && |
36 | | - sed -r -i \"s/currently\\s+\\*\\*\\[v[0-9.]+\]/currently **[v$$WP_LATEST]/\" /app/README.md |
37 | | - echo -e \"✅ Done!\"" |
38 | | -
|
39 | | -
|
40 | | -
|
41 | | -# TODO: Check DockerHub for existance of the latest release beffore continuing? |
42 | | - |
43 | | -# https://registry.hub.docker.com/v2/repositories/library/wordpress/tags/5.9.1 |
44 | | - |
45 | | -# unknown tags return a 404: |
46 | | - |
47 | | -# https://registry.hub.docker.com/v2/repositories/library/wordpress/tags/7.9.4 |
48 | | - |
49 | | - |
50 | | -# sed -E -i "s/currently\s+\*\*\[[0-9.]+]/currently **[$WP_LATEST]/" README.md |
51 | | - |
52 | | - |
53 | | -# https://registry.hub.docker.com/v1/repositories/wordpress/tags |
54 | | - |
55 | | -# https://registry.hub.docker.com/v2/repositories/library/wordpress/tags?page_size=100 |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | | -# cat wp.json| jq 'to_entries[] | select(.value == "latest") | { wordpress: .key, image: (.key + "-v")}' > wp-latest.json |
61 | | -# jq -s '.[0] * (.[1] | {version})' wp-latest.json package.json |
62 | | -# jq -s '.[0] * .[1] | {wordpress, image: (.wordpress + "-v" + .version)}' wp-latest.json package.json |
63 | | - |
64 | | -# jq -s '(.[0].to_entries[] | select(.value == "latest")) * .[1]' wp.json package.json |
65 | | - |
66 | | - |
67 | | -# jq -s '{wordpress: .[0] | to_entries[] | select(.value == "latest").key, version: .[1].version } | {wordpress, image: (.wordpress + "-v" + .version)}' wp.json package.json |
68 | | -# { |
69 | | -# "wordpress": "5.9.2", |
70 | | -# "image": "5.9.2-v0.8.1" |
71 | | -# } |
72 | | - |
73 | | - |
74 | | - |
75 | | - # jq -s ' |
76 | | - # { |
77 | | - # wordpress: .[0] |
78 | | - # | to_entries[] |
79 | | - # | select(.value == \"latest\").key, |
80 | | - # version: .[1].version |
81 | | - # } | { |
82 | | - # wordpress, |
83 | | - # image: (.wordpress + \"-v\" + .version)}' \\ |
84 | | - # /tmp/wp.json /app/package.json > /app/release.json && |
85 | | - # WP_LATEST=$$(jq -r '.wordpress' /app/release.json) && |
86 | | - |
87 | | - |
88 | | - |
89 | | - # 1. Fetch list of stable WordPress versions from the wordpress.org api |
90 | | - # 2. Parse the API result and generate a JSON metadata file in containing |
91 | | - # the latest WordPress version and a full image name from the combined |
92 | | - # WordPress version and the project's version from package.json |
93 | | - # 3. Fetches the latest WordPress release from the JSON file and updates |
94 | | - # the base image in the DockerFile. |
95 | | - # |
96 | | - # |
97 | | - # The generated /tmp/release.json file looks like this: |
98 | | - # { |
99 | | - # "wordpress": "5.9.2", |
100 | | - # "image": "5.9.2-v0.8.1" |
101 | | - # } |
102 | | - |
| 11 | + sh /app/bin/bump-wordpress.sh |
0 commit comments