Skip to content

Commit cfcd610

Browse files
committed
Add Simple Commit and Push Action
1 parent e6a39e1 commit cfcd610

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Test Simple Commit and Push
2+
3+
on:
4+
push:
5+
paths:
6+
- '.github/workflows/test-simple-commit-and-push.yml'
7+
pull_request:
8+
paths:
9+
- '.github/workflows/test-simple-commit-and-push.yml'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
check:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Install Task
24+
uses: arduino/setup-task@v2
25+
with:
26+
version: 3.x
27+
repo-token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Install mise and setup
30+
uses: jdx/mise-action@v2
31+
with:
32+
cache: true
33+
github_token: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Setup tools
36+
run: task setup
37+
38+
- name: Create a test file
39+
run: echo "This is a test file." > test-file.txt
40+
41+
- name: 'Test-01: use default inputs'
42+
uses: satt-dots/simple-commit-and-push@main # TODO: change to tag `v1`
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: 'Test-01: Check latest commit info'
47+
run: |
48+
set -e
49+
AUTHOR_NAME=$(git show -s --format='%an')
50+
AUTHOR_EMAIL=$(git show -s --format='%ae')
51+
COMMIT_MSG=$(git show -s --format='%s')
52+
echo "author: $AUTHOR_NAME"
53+
echo "email: $AUTHOR_EMAIL"
54+
echo "message: $COMMIT_MSG"
55+
test "$AUTHOR_NAME" = "GitHub Action"
56+
test "$AUTHOR_EMAIL" = "action@github.com"
57+
test "$COMMIT_MSG" = "Auto commit"
58+
59+
- name: Remove test file
60+
run: rm -f test-file.txt
61+
62+
- name: 'Test-02: not use default inputs'
63+
uses: satt-dots/simple-commit-and-push@main # TODO: change to tag `v1`
64+
with:
65+
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
commit-message: "Commit message for testing"
67+
user-email: 41898282+github-actions[bot]@users.noreply.github.com
68+
user-name: github-actions[bot]
69+
70+
- name: 'Test-02: Check latest commit info'
71+
run: |
72+
set -e
73+
AUTHOR_NAME=$(git show -s --format='%an')
74+
AUTHOR_EMAIL=$(git show -s --format='%ae')
75+
COMMIT_MSG=$(git show -s --format='%s')
76+
echo "author: $AUTHOR_NAME"
77+
echo "email: $AUTHOR_EMAIL"
78+
echo "message: $COMMIT_MSG"
79+
test "$AUTHOR_NAME" = "github-actions[bot]"
80+
test "$AUTHOR_EMAIL" = "41898282+github-actions[bot]@users.noreply.github.com"
81+
test "$COMMIT_MSG" = "Commit message for testing"
82+
83+
- name: 'Test-03: set hash before'
84+
run: |
85+
HASH=$(git rev-parse HEAD)
86+
echo "HASH_AFTER_TEST02=$HASH" >> $GITHUB_ENV
87+
88+
- name: 'Test-03: no changes'
89+
uses: satt-dots/simple-commit-and-push@main # TODO: change to tag `v1`
90+
with:
91+
github-token: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: 'Test-03: Check latest commit info'
94+
run: |
95+
set -e
96+
HASH_BEFORE="$HASH_AFTER_TEST02"
97+
HASH_AFTER=$(git rev-parse HEAD)
98+
echo "HASH_BEFORE: $HASH_BEFORE"
99+
echo "HASH_AFTER: $HASH_AFTER"
100+
test "$HASH_BEFORE" = "$HASH_AFTER"

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Shared Github Actions
2+
3+
共有 Action の一覧と外部からのテストを行うためのリポジトリです。
4+
5+
## Actions
6+
7+
- [Simple Commit and Push Action](https://github.com/satt-dots/simple-commit-and-push)

0 commit comments

Comments
 (0)