Skip to content

Commit 22a3666

Browse files
authored
Merge pull request #23 from haya14busa/composite
Convert this docker based action to composite action
2 parents fb48464 + 4bccbe0 commit 22a3666

5 files changed

Lines changed: 47 additions & 37 deletions

File tree

.github/workflows/dockerimage.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/reviewdog.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,6 @@ jobs:
2222
reporter: ${{ steps.reporter.outputs.value }}
2323
level: warning
2424

25-
hadolint:
26-
name: runner / hadolint
27-
runs-on: ubuntu-latest
28-
steps:
29-
- uses: actions/checkout@v2
30-
- uses: haya14busa/action-cond@v1
31-
id: reporter
32-
with:
33-
cond: ${{ github.event_name == 'pull_request' }}
34-
if_true: "github-pr-review"
35-
if_false: "github-check"
36-
- uses: reviewdog/action-hadolint@v1
37-
with:
38-
github_token: ${{ secrets.github_token }}
39-
reporter: ${{ steps.reporter.outputs.value }}
40-
level: warning
41-
4225
misspell:
4326
name: runner / misspell
4427
runs-on: ubuntu-latest

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# GitHub Action: Update major/minor semver
22

3-
[![Docker Image CI](https://github.com/haya14busa/action-update-semver/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/haya14busa/action-update-semver/actions)
43
[![reviewdog](https://github.com/haya14busa/action-update-semver/workflows/reviewdog/badge.svg)](https://github.com/haya14busa/action-update-semver/actions?query=workflow%3Areviewdog)
54
[![release](https://github.com/haya14busa/action-update-semver/workflows/release/badge.svg)](https://github.com/haya14busa/action-update-semver/actions?query=workflow%3Arelease)
65
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/haya14busa/action-update-semver?logo=github&sort=semver)](https://github.com/haya14busa/action-update-semver/releases)
@@ -26,7 +25,7 @@ It works well for GitHub Action. ref: https://help.github.com/en/articles/about-
2625

2726
### `github_token`
2827

29-
**Optional**. It's no need to specify it if you use checkout@v2. Required for
28+
**Optional**. It's no need to specify it if you use checkout@v2 or later. Required for
3029
checkout@v1 action.
3130

3231

@@ -46,7 +45,7 @@ jobs:
4645
update-semver:
4746
runs-on: ubuntu-latest
4847
steps:
49-
- uses: actions/checkout@v2
48+
- uses: actions/checkout@v4
5049
- uses: haya14busa/action-update-semver@v1
5150
with:
5251
major_version_tag_only: true # (optional, default is "false")
@@ -69,7 +68,7 @@ jobs:
6968
update-semver:
7069
runs-on: ubuntu-latest
7170
steps:
72-
- uses: actions/checkout@v1
71+
- uses: actions/checkout@v4
7372
- uses: haya14busa/action-update-semver@v1
7473
with:
7574
github_token: \${{ secrets.github_token }}

action.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ inputs:
1616
required: false
1717

1818
runs:
19-
using: 'docker'
20-
image: 'Dockerfile'
19+
using: 'composite'
20+
steps:
21+
- name: Update major/minor semver tags
22+
shell: bash
23+
env:
24+
INPUT_TAG: ${{ inputs.tag }}
25+
INPUT_MESSAGE: ${{ inputs.message }}
26+
INPUT_MAJOR_VERSION_TAG_ONLY: ${{ inputs.major_version_tag_only }}
27+
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
28+
run: ${{ github.action_path }}/script.sh
2129
# Ref: https://haya14busa.github.io/github-action-brandings/
2230
branding:
2331
icon: 'refresh-cw'

script.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
set -x
3+
4+
cd "${GITHUB_WORKSPACE}" || exit
5+
6+
# Set up variables.
7+
TAG="${INPUT_TAG:-${GITHUB_REF#refs/tags/}}" # v1.2.3
8+
MINOR="${TAG%.*}" # v1.2
9+
MAJOR="${MINOR%.*}" # v1
10+
MAJOR_VERSION_TAG_ONLY=${INPUT_MAJOR_VERSION_TAG_ONLY:-}
11+
12+
if [ "${GITHUB_REF}" = "${TAG}" ]; then
13+
echo "This workflow is not triggered by tag push: GITHUB_REF=${GITHUB_REF}"
14+
exit 1
15+
fi
16+
17+
MESSAGE="${INPUT_MESSAGE:-Release ${TAG}}"
18+
19+
# Set up Git.
20+
git config user.name "${GITHUB_ACTOR}"
21+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
22+
23+
# Update MAJOR/MINOR tag
24+
git tag -fa "${MAJOR}" -m "${MESSAGE}"
25+
[ "${MAJOR_VERSION_TAG_ONLY}" = "true" ] || git tag -fa "${MINOR}" -m "${MESSAGE}"
26+
27+
# Set up remote url for checkout@v1 action.
28+
if [ -n "${INPUT_GITHUB_TOKEN}" ]; then
29+
git remote set-url origin "https://${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
30+
fi
31+
32+
# Push
33+
[ "${MAJOR_VERSION_TAG_ONLY}" = "true" ] || git push --force origin "${MINOR}"
34+
git push --force origin "${MAJOR}"

0 commit comments

Comments
 (0)