-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Upgrade/replace GitHub actions #10384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stephanos
wants to merge
33
commits into
main
Choose a base branch
from
stephanos/node-20-depre
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
ef7cf5e
Update GitHub Actions for Node 24
stephanos 473e209
Replace Node 20 workflow actions
stephanos 9858d06
Integrate Docker cache into compose action
stephanos edc7e82
Generalize docker compose action
stephanos 50f06fe
Rename docker compose teardown steps
stephanos 10a6368
Clean up docker compose action branching
stephanos 1dad919
Split docker compose start and stop actions
stephanos 8e98afb
Infer docker compose cache key
stephanos b138aaa
Simplify docker compose start scripts
stephanos 2250c61
Document docker compose cache scripting
stephanos eff4d78
Simplify docker compose stop condition
stephanos fd5b8f7
Simplify single test compose guards
stephanos 864469d
Remove redundant compose start guard
stephanos 68130a7
Use raw compose services for cache key
stephanos b97c900
Use hashFiles for compose cache key
stephanos 6c6ede8
Simplify compose start cache guards
stephanos b162966
Deduplicate compose cache key
stephanos 0f58b87
Avoid expression interpolation in compose script
stephanos 28045ad
Update github-script to v9
stephanos cc7b57a
Add permissions to promote docker workflow
stephanos 5ce7ce7
Wait for compose services on start
stephanos 2219337
Align compose cache with requested services
stephanos acce778
Make compose up flags configurable
stephanos 6a56486
Pass compose wait flag explicitly
stephanos 3a632e5
Rename compose start flags input
stephanos bbca562
Add docker compose healthy action
stephanos cd1a623
Move compose wait to healthy action
stephanos 1289548
Reuse integration compose services
stephanos a9f0a5d
Reuse matrix compose services
stephanos dacc257
Always run compose healthy action
stephanos ebeb79c
Fix docker compose service inputs
stephanos 06f41a2
🐍
stephanos 0fd4c7b
this, too
stephanos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: Docker Compose Healthy | ||
| description: Wait for Docker Compose services to become healthy. | ||
|
|
||
| inputs: | ||
| compose_file: | ||
| description: Docker Compose file to use. | ||
| required: true | ||
| services: | ||
| description: Whitespace-delimited list of services to wait for. | ||
| default: "" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Wait for services | ||
| shell: bash | ||
| env: | ||
| COMPOSE_FILE: ${{ inputs.compose_file }} | ||
| SERVICES: ${{ inputs.services }} | ||
| run: | | ||
| if [[ -z "${SERVICES//[[:space:]]/}" ]]; then | ||
| echo "No services configured for docker compose healthy." | ||
| exit 0 | ||
| fi | ||
|
|
||
| read -r -a services <<< "$SERVICES" | ||
| docker compose -f "$COMPOSE_FILE" up --wait "${services[@]}" |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| name: Docker Compose Start | ||
| description: Restore Docker image cache, pull Docker Compose services with retries, then start them. | ||
|
|
||
| inputs: | ||
| compose_file: | ||
| description: Docker Compose file to use. | ||
| required: true | ||
| services: | ||
| description: Whitespace-delimited list of services to start. | ||
| default: "" | ||
| attempts: | ||
| description: Number of pull attempts. | ||
| default: "5" | ||
| delay_seconds: | ||
| description: Delay between failed attempts. | ||
| default: "5" | ||
| timeout_minutes: | ||
| description: Timeout for each pull attempt. | ||
| default: "1" | ||
| flags: | ||
| description: Additional options to pass to docker compose up. | ||
| default: "" | ||
| cache: | ||
| description: Set to "true" to cache Docker images. | ||
| default: "false" | ||
| cache_path: | ||
| description: Directory used to store the Docker image archive. | ||
| default: ${{ runner.temp }}/docker-image-cache | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Prepare Docker image cache | ||
| id: cache | ||
| if: ${{ inputs.cache == 'true' }} | ||
| shell: bash | ||
| env: | ||
| COMPOSE_HASH: ${{ hashFiles(inputs.compose_file) }} | ||
| SERVICES: ${{ inputs.services }} | ||
| run: | | ||
| services_hash="$(printf '%s' "$SERVICES" | shasum -a 256 | cut -d ' ' -f 1)" | ||
|
|
||
| echo "key=docker-${RUNNER_OS}${RUNNER_ARCH}-${COMPOSE_HASH}-${services_hash}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Restore Docker image cache | ||
| id: restore-cache | ||
| if: ${{ inputs.cache == 'true' }} | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: ${{ inputs.cache_path }} | ||
| key: ${{ steps.cache.outputs.key }} | ||
|
|
||
| - name: Load Docker images | ||
| if: ${{ inputs.cache == 'true' && steps.restore-cache.outputs.cache-hit == 'true' }} | ||
| shell: bash | ||
| env: | ||
| CACHE_PATH: ${{ inputs.cache_path }} | ||
| run: | | ||
| if [[ -f "$CACHE_PATH/images.tar" ]]; then | ||
| docker load --input "$CACHE_PATH/images.tar" | ||
| else | ||
| echo "Docker image cache hit did not include images.tar." | ||
| fi | ||
|
|
||
| - name: Pull services | ||
| if: ${{ steps.restore-cache.outputs.cache-hit != 'true' }} | ||
| uses: nick-fields/retry@v4 | ||
| env: | ||
| COMPOSE_FILE: ${{ inputs.compose_file }} | ||
| SERVICES: ${{ inputs.services }} | ||
| with: | ||
| max_attempts: ${{ inputs.attempts }} | ||
| retry_wait_seconds: ${{ inputs.delay_seconds }} | ||
| timeout_minutes: ${{ inputs.timeout_minutes }} | ||
| shell: bash | ||
| command: | | ||
| if [[ -z "${SERVICES//[[:space:]]/}" ]]; then | ||
| echo "No services configured for docker compose pull." | ||
| exit 0 | ||
| fi | ||
| docker compose -f "$COMPOSE_FILE" pull $SERVICES | ||
|
|
||
| - name: Start services | ||
| shell: bash | ||
| env: | ||
| COMPOSE_FILE: ${{ inputs.compose_file }} | ||
| SERVICES: ${{ inputs.services }} | ||
| FLAGS: ${{ inputs.flags }} | ||
| run: | | ||
| if [[ -z "${SERVICES//[[:space:]]/}" ]]; then | ||
| echo "No services configured for docker compose up." | ||
| exit 0 | ||
| fi | ||
| docker compose -f "$COMPOSE_FILE" up -d $FLAGS $SERVICES | ||
|
|
||
| - name: Save Docker images to archive | ||
| id: archive | ||
| if: ${{ inputs.cache == 'true' && steps.restore-cache.outputs.cache-hit != 'true' }} | ||
| shell: bash | ||
| env: | ||
| CACHE_PATH: ${{ inputs.cache_path }} | ||
| COMPOSE_FILE: ${{ inputs.compose_file }} | ||
| SERVICES: ${{ inputs.services }} | ||
| run: | | ||
| mkdir -p "$CACHE_PATH" | ||
| images_file="$CACHE_PATH/images.txt" | ||
| : > "$images_file" | ||
|
|
||
| # Only cache images that were actually pulled for this job's services. | ||
| while IFS= read -r image; do | ||
| if docker image inspect "$image" >/dev/null 2>&1; then | ||
| printf '%s\n' "$image" >> "$images_file" | ||
| fi | ||
| done < <(docker compose -f "$COMPOSE_FILE" config --images $SERVICES | sort -u) | ||
|
|
||
| if [[ ! -s "$images_file" ]]; then | ||
| echo "No Docker images are available to cache." | ||
| echo "cacheable=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| mapfile -t images < "$images_file" | ||
| docker save --output "$CACHE_PATH/images.tar" "${images[@]}" | ||
| echo "cacheable=true" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Save Docker image cache | ||
| if: ${{ inputs.cache == 'true' && steps.archive.outputs.cacheable == 'true' }} | ||
| uses: actions/cache/save@v5 | ||
| with: | ||
| path: ${{ inputs.cache_path }} | ||
| key: ${{ steps.cache.outputs.key }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: Docker Compose Stop | ||
| description: Stop Docker Compose services. | ||
|
|
||
| inputs: | ||
| compose_file: | ||
| description: Docker Compose file to use. | ||
| required: true | ||
| flags: | ||
| description: Additional options to pass to docker compose down. | ||
| default: "" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Stop services | ||
| shell: bash | ||
| env: | ||
| COMPOSE_FILE: ${{ inputs.compose_file }} | ||
| FLAGS: ${{ inputs.flags }} | ||
| run: | | ||
| docker compose -f "$COMPOSE_FILE" down $FLAGS | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could arguably be inlined, but I like the parity of the start/stop actions.