Skip to content

feat: Add support for Tags push events #39

feat: Add support for Tags push events

feat: Add support for Tags push events #39

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 12 * * 5'
permissions:
contents: read
concurrency:
group: test-action
cancel-in-progress: ${{ github.ref != 'main' }}
jobs:
test-jest:
name: Jest Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Install Dependencies
run: npm ci
- name: Check Format
run: npm run format:check
- name: Lint
run: npm run lint
- name: Test
run: npm run ci-test
test-action-basic:
name: GitHub Actions Test (Basic)
runs-on: ubuntu-latest
permissions:
contents: write
env:
BRANCH: test-action-basic
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test Action
id: test-action
uses: ./
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
test.txt
commit-message: Add Dummy Content
- name: Print Action Output
run: echo "${{ steps.test-action.outputs.commit-sha }}"
- name: Clean up test action environment
shell: bash
if: always()
run: |
test_branch=$(git ls-remote --heads origin refs/heads/$BRANCH)
if [[ -n $test_branch ]]; then
echo "test branch $BRANCH existed"
git push -d origin refs/heads/$BRANCH
else
echo "test branch $BRANCH does not exist"
fi
test-action-branch:
name: GitHub Actions Test (Custom Branch)
runs-on: ubuntu-latest
permissions:
contents: write
needs: test-action-basic
env:
BRANCH: test-action-branch
steps:
- name: Checkout
uses: actions/checkout@v4
- name: generate dummy content
shell: bash
run: |
touch test.txt && echo 'xyz' > test.txt
- name: Test Action
id: test-action
uses: ./
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
test.txt
commit-message: Add Dummy Content
branch-name: ${{ env.BRANCH }}
branch-push-force: true
- name: Print Action Output
run: echo "${{ steps.test-action.outputs.commit-sha }}"
- name: Clean up test action environment
shell: bash
if: always()
run: |
test_branch=$(git ls-remote --heads origin refs/heads/$BRANCH)
if [[ -n $test_branch ]]; then
echo "test branch $BRANCH existed"
git push -d origin refs/heads/$BRANCH
else
echo "test branch $BRANCH does not exist"
fi
test-action-workspace:
name: GitHub Actions Test (Workspace)
runs-on: ubuntu-latest
permissions:
contents: write
needs: test-action-branch
env:
BRANCH: test-action-workspace
steps:
- name: Checkout
uses: actions/checkout@v4
- name: generate dummy content
shell: bash
run: |
mkdir dummy
touch dummy/test.txt && echo '123' > dummy/test.txt
- name: Test Action
id: test-action
uses: ./
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
test.txt
commit-message: Add Dummy Content
branch-name: ${{ env.BRANCH }}
workspace: dummy
- name: Print Action Output
run: echo "${{ steps.test-action.outputs.commit-sha }}"
- name: Clean up test action environment
shell: bash
if: always()
run: |
test_branch=$(git ls-remote --heads origin refs/heads/$BRANCH)
if [[ -n $test_branch ]]; then
echo "test branch $BRANCH existed"
git push -d origin refs/heads/$BRANCH
else
echo "test branch $BRANCH does not exist"
fi
test-action-glob:
name: GitHub Actions Test (Glob)
runs-on: ubuntu-latest
permissions:
contents: write
needs: test-action-workspace
env:
BRANCH: test-action-glob
steps:
- name: Checkout
uses: actions/checkout@v4
- name: generate dummy content
shell: bash
run: |
touch test_1.txt && echo 'abc123' > test_1.txt
touch test_2.txt && echo 'abc456' > test_2.txt
- name: Test Action
id: test-action
uses: ./
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
test*.txt
commit-message: Add Dummy Content
branch-name: ${{ env.BRANCH }}
- name: Print Action Output
run: echo "${{ steps.test-action.outputs.commit-sha }}"
- name: Clean up test action environment
shell: bash
if: always()
run: |
test_branch=$(git ls-remote --heads origin refs/heads/$BRANCH)
if [[ -n $test_branch ]]; then
echo "test branch $BRANCH existed"
git push -d origin refs/heads/$BRANCH
else
echo "test branch $BRANCH does not exist"
fi
test-action-tag:
name: GitHub Actions Test (Tag)
runs-on: ubuntu-latest
permissions:
contents: write
needs: test-action-glob
env:
TAG: v1.2.3
BRANCH: test-action-tag
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test Action
id: test-action
uses: ./
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch-name: ${{ env.BRANCH }}
tag: ${{ env.TAG }}
- name: Print Action Output
run: |
echo "[commit] ${{ steps.test-action.outputs.commit-sha }}"
echo "[tag] ${{ steps.test-action.outputs.tag }}"
- name: Clean up test action environment
shell: bash
if: always()
run: |
test_branch=$(git ls-remote --heads origin refs/heads/$BRANCH)
if [[ -n $test_branch ]]; then
echo "test branch $BRANCH existed"
git push -d origin refs/heads/$BRANCH
else
echo "test branch $BRANCH does not exist"
fi
test_tag=$(git ls-remote --tags origin refs/tags/$TAG)
if [[ -n $test_tag ]]; then
echo "test tag $TAG existed"
git push -d origin refs/tags/$TAG
else
echo "test tag $TAG does not exist"
fi
test-action-file-tag:
name: GitHub Actions Test (File & Tag)
runs-on: ubuntu-latest
permissions:
contents: write
needs: test-action-tag
env:
BRANCH: test-action-file-tag
TAG: 4.5.6
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: generate dummy content
shell: bash
run: |
touch test_1.txt && echo 'abc123' > test_1.txt
touch test_2.txt && echo 'abc456' > test_2.txt
- name: Test Action
id: test-action
uses: ./
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
test*.txt
commit-message: Add Dummy Content
branch-name: ${{ env.BRANCH }}
tag: ${{ env.TAG }}
- name: Print Action Output
run: |
echo "[commit] ${{ steps.test-action.outputs.commit-sha }}"
echo "[tag] ${{ steps.test-action.outputs.tag }}"
- name: Clean up test action environment
shell: bash
if: always()
run: |
test_branch=$(git ls-remote --heads origin refs/heads/$BRANCH)
if [[ -n $test_branch ]]; then
echo "test branch $BRANCH existed"
git push -d origin refs/heads/$BRANCH
else
echo "test branch $BRANCH does not exist"
fi
test_tag=$(git ls-remote --tags origin refs/tags/$TAG)
if [[ -n $test_tag ]]; then
echo "test tag $TAG existed"
git push -d origin refs/tags/$TAG
else
echo "test tag $TAG does not exist"
fi
test-action-no-file-changes-tag:
name: GitHub Actions Test (No File Changes & Tag)
runs-on: ubuntu-latest
permissions:
contents: write
needs: test-action-file-tag
env:
BRANCH: test-action-no-file-changes-tag
TAG: 7.8.9
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test Action
id: test-action
uses: ./
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: README.md
commit-message: Add Dummy Content
branch-name: ${{ env.BRANCH }}
tag: ${{ env.TAG }}
- name: Print Action Output
run: |
echo "[commit] ${{ steps.test-action.outputs.commit-sha }}"
echo "[tag] ${{ steps.test-action.outputs.tag }}"
- name: Clean up test action environment
shell: bash
if: always()
run: |
test_branch=$(git ls-remote --heads origin refs/heads/$BRANCH)
if [[ -n $test_branch ]]; then
echo "test branch $BRANCH existed"
git push -d origin refs/heads/$BRANCH
else
echo "test branch $BRANCH does not exist"
fi
test_tag=$(git ls-remote --tags origin refs/tags/$TAG)
if [[ -n $test_tag ]]; then
echo "test tag $TAG existed"
git push -d origin refs/tags/$TAG
else
echo "test tag $TAG does not exist"
fi