Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: planetscale/ghcommit-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.43
Choose a base ref
...
head repository: planetscale/ghcommit-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.1.44
Choose a head ref
  • 6 commits
  • 4 files changed
  • 2 contributors

Commits on Jul 21, 2024

  1. feat: provide the commit information as output

    Henkru committed Jul 21, 2024
    Copy the full SHA
    ff17660 View commit details

Commits on Jul 22, 2024

  1. Merge pull request #65 from Henkru/commit-output

    feat: provide the commit information as output
    joemiller authored Jul 22, 2024
    Copy the full SHA
    5230710 View commit details

Commits on Aug 5, 2024

  1. fix tests

    recent changes modified the stdout from the entrypoint.sh script. update
    the tests to reflect this
    joemiller committed Aug 5, 2024
    Copy the full SHA
    b330e62 View commit details
  2. Merge pull request #68 from planetscale/fix-ci

    fix tests
    joemiller authored Aug 5, 2024
    Copy the full SHA
    61331f3 View commit details
  3. force release

    the 'release' step in the GHA workflow has a filter to only cut new
    releases on certain files changing. the previous PR only updated the
    tests so a new release was not cut, but we need to cut a new release to
    get the recent GITHUB_OUTPUT feature out
    joemiller committed Aug 5, 2024
    Copy the full SHA
    1fb4616 View commit details
  4. Merge pull request #69 from planetscale/force-release

    force release
    joemiller authored Aug 5, 2024
    Copy the full SHA
    c7915d6 View commit details
Showing with 30 additions and 3 deletions.
  1. +2 −0 Dockerfile
  2. +6 −0 action.yaml
  3. +11 −1 entrypoint.sh
  4. +11 −2 tests/entrypoint.bats
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM ghcr.io/planetscale/ghcommit:v0.1.48@sha256:9ebf836e2bdbb88e536984312a9083af8c95487ad2b59a1d830672bf4d9053ea AS ghcommit

# hadolint ignore=DL3007
FROM pscale.dev/wolfi-prod/base:latest AS base

COPY --from=ghcommit /ghcommit /usr/bin/ghcommit

# hadolint ignore=DL3018
RUN apk add --no-cache \
bash \
git
6 changes: 6 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -24,6 +24,12 @@ inputs:
required: false
default: "."

outputs:
commit-url:
description: The URL of the created commit.
commit-hash:
description: The hash of the created commit.

runs:
using: "docker"
image: "Dockerfile"
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -74,4 +74,14 @@ ghcommit_args+=("${deletes[@]/#/--delete=}")

[[ -n "${DEBUG:-}" ]] && echo "ghcommit args: '${ghcommit_args[*]}'"

ghcommit "${ghcommit_args[@]}"
output=$(ghcommit "${ghcommit_args[@]}" 2>&1) || {
# Show the output on error. This is needed since the exit immediately flag is set.
echo "$output" 1>&2;
exit 1
}
echo "$output"

commit_url=$(echo "$output" | grep "Success. New commit:" | awk '{print $NF}')
commit_hash=$(echo "$commit_url" | awk -F '/' '{print $NF}')
echo "commit-url=$commit_url" >> "$GITHUB_OUTPUT"
echo "commit-hash=$commit_hash" >> "$GITHUB_OUTPUT"
13 changes: 11 additions & 2 deletions tests/entrypoint.bats
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"

setup() {
export GITHUB_WORKSPACE=/tmp
#export DEBUG=1
}

@test "parses git status output and generates correct flags for ghcommit" {
@@ -17,6 +18,8 @@ setup() {
local empty='false'
local file_pattern='.'

export GITHUB_OUTPUT="$BATS_TEST_TMPDIR/github-output"

# NOTE: we are passing our hand-crafted fixture through `tr` to convert newlines to nulls since
# we run `git status -z` which uses null terminators. The newlines are meant to make the file easier
# to modify and prevent cat from removing the leading space on lines/entries since that is a part
@@ -26,11 +29,13 @@ setup() {
"status -s --porcelain=v1 -z -- . : cat ./tests/fixtures/git-status.out-1 | tr '\n' '\0'"

stub ghcommit \
'-b main -r org/repo -m msg --add=README.md --add=foo.txt --add=new.file --delete=old.file --delete=\""a path with spaces oh joy/file.txt\"" : echo Success'
'-b main -r org/repo -m msg --add=README.md --add=foo.txt --add=new.file --delete=old.file --delete=\""a path with spaces oh joy/file.txt\"" : echo Success. New commit: https://localhost/foo'

run ./entrypoint.sh "$commit_message" "$repo" "$branch" "$empty" "$file_pattern"
assert_success
assert_output --partial "Success"
assert_file_exist "$GITHUB_OUTPUT"
assert_file_contains "$GITHUB_OUTPUT" "commit-url=https://localhost/foo"
}

@test "no changes" {
@@ -56,14 +61,18 @@ setup() {
local empty='true'
local file_pattern='.'

export GITHUB_OUTPUT="$BATS_TEST_TMPDIR/github-output"

stub git \
"config --global --add safe.directory $GITHUB_WORKSPACE : echo stubbed" \
"status -s --porcelain=v1 -z -- . : echo"

stub ghcommit \
'-b main -r org/repo -m msg --empty : echo Success'
'-b main -r org/repo -m msg --empty : echo Success. New commit: https://localhost/foo'

run ./entrypoint.sh "$commit_message" "$repo" "$branch" "$empty" "$file_pattern"
assert_success
assert_output --partial "Success"
assert_file_exist "$GITHUB_OUTPUT"
assert_file_contains "$GITHUB_OUTPUT" "commit-url=https://localhost/foo"
}