Skip to content

Merge template repository changes: remal-github-actions/template-composite #49

Merge template repository changes: remal-github-actions/template-composite

Merge template repository changes: remal-github-actions/template-composite #49

Workflow file for this run

name: build
on:
push:
branches:
- main
pull_request: { }
defaults:
run:
shell: bash
jobs:
build:
if: ${{
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|| (github.event_name == 'push' && !startsWith(github.event.head_commit.message, '[push-back]'))
|| github.event_name != 'push'
}}
concurrency:
group: build-${{github.ref}}
cancel-in-progress: true
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{secrets.PUSH_BACK_TOKEN}}
submodules: recursive
lfs: true
fetch-depth: 1
# $$$sync-with-template-modifiable: validation $$$
- name: Change origin repository to simulate remote change
if: ${{github.ref == 'refs/heads/main'}}
env:
GITHUB_TOKEN: ${{secrets.PUSH_BACK_TOKEN}}
run: |
PATH_IN_REPO=".last-build-date"
gh api \
--header "Accept: application/vnd.github+json" \
"/repos/${{github.repository}}/contents/$PATH_IN_REPO" > file.json
SHA=$(jq -r '.sha' file.json)
gh api \
--method PUT \
--header "Accept: application/vnd.github+json" \
"/repos/${{github.repository}}/contents/$PATH_IN_REPO" \
--field message="[push-back] origin change to test" \
--field content="$(date +"%Y-%m-%d %H:%M:%S" | base64 -w0)" \
--field sha="$SHA"
- name: Generate a file to commit
run: |
echo "This is a test file" > test-file.txt
- name: Run current action
id: current
uses: ./
with:
dryRun: 'true'
message: 'Test message'
- name: Validate output
run: |
if [ "${{steps.current.outputs.result}}" != "${{github.ref == 'refs/heads/main' && 'remote-changed' || 'pushed-successfully'}}" ]; then
echo "::error::Unexpected result: ${{steps.current.outputs.result}}"
exit 1
fi
# $$$sync-with-template-modifiable-end$$$
- name: Get version
id: get-version
run: |
VERSION=$(yq '.version' action.yml)
if [[ "$VERSION" == "null" ]]; then
echo "::error::Couldn't read version from action.yml"
exit 1
fi
echo "version=$VERSION" | tee -a $GITHUB_OUTPUT
- name: Create tag
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
uses: remal-github-actions/create-tag@v2
with:
tagName: 'v${{steps.get-version.outputs.version}}'