diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..42ff651 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,57 @@ +name: test + +on: + push: + branches: + - test + +env: + DOCKER_IMAGE: chuhlomin/render-template + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: PR Features + id: pr_features + run: | + FEATURE_COMMITS=$(git log remotes/origin/main..feat/funcs --oneline --pretty=format:"%s" | grep -E '^(feat!|feat|fix|docs)') + echo "${FEATURE_COMMITS}" + { + echo 'pr_features<> $GITHUB_OUTPUT + + - name: PR Notes + id: pr_notes + run: | + COMMIT_BODIES=$(git log remotes/origin/main..feat/funcs --pretty=format:"%s%n%b" | awk '/^(feat!|feat|fix|docs)/ {inBody=1; next} inBody {print $0; next} {inBody=0}') + echo "${COMMIT_BODIES}" + { + echo 'pr_notes<> $GITHUB_OUTPUT + + - name: Get Current Date + id: get_current_date + run: | + CURRENT_DATE=$(date +"%Y-%m-%d") + echo "current_date=${CURRENT_DATE}" >> $GITHUB_OUTPUT + + - name: Test action + uses: ./ # Uses an action in the root directory + id: render + with: + template: ./testdata/pull_request_template.md + vars: | + pr_date: ${{ steps.get_current_date.outputs.current_date }} + pr_feature: "${{ steps.pr_features.outputs.pr_features }}" + pr_notes: "${{ steps.pr_notes.outputs.pr_notes }}" + + - name: Get `result` output + run: echo "${{ steps.render.outputs.result }}" diff --git a/testdata/pull_request_template.md b/testdata/pull_request_template.md new file mode 100644 index 0000000..16c71ca --- /dev/null +++ b/testdata/pull_request_template.md @@ -0,0 +1,11 @@ +

🤖 Reg created a pull request beep boop

+ +

{{ .pr_date | date "2006-01-02" }}

+ +

Features

+ +{{ .pr_feature }} + +

Notes

+ +{{ .pr_notes }}