Update Versiondate #2611
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: controlsFile | |
on: | |
push: | |
paths: | |
- 'FHEM/**' | |
- '.github/workflows/update.yml' | |
jobs: | |
pr_check: | |
outputs: | |
result: ${{ steps.checkbranch.outputs.result }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Extract branch name | |
id: extract_branch | |
run: | | |
echo "BRANCH_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
- name: Check if Branch is in PR | |
if: github.event_name == 'push' | |
id: checkbranch | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
console.log(process.env.BRANCH_NAME) | |
const resp = await github.rest.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
if (resp.data) { | |
const pullRequestsWithBranch = resp.data.filter(it => it.head.ref == process.env.BRANCH_NAME && it.head.label.startsWith(context.repo.owner) ) | |
console.log(pullRequestsWithBranch) | |
return pullRequestsWithBranch.length >= 1 | |
} | |
return false | |
env: | |
BRANCH_NAME: ${{ steps.extract_branch.outputs.BRANCH_NAME }} | |
update: | |
needs: pr_check | |
if: needs.pr_check.outputs.result != 'true' | |
env: | |
CONTROLS_FILENAME: controls_signalduino.txt | |
runs-on: ubuntu-latest | |
steps: | |
- name: output | |
if: needs.pr_check.outputs.result != 'true' | |
env: | |
SENDER: ${{ toJson(github.event.sender) }} | |
PR: ${{ toJson(github.event.push) }} | |
PUSHER: §${{ toJson(github.event.pusher) }} | |
run: | | |
echo "$SENDER" | |
echo "$PR" | |
echo "$PUSHER" | |
- name: Extract branch name | |
if: needs.pr_check.outputs.result != 'true' | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
id: extract_branch | |
- name: Checkout Repostory | |
if: needs.pr_check.outputs.result != 'true' | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: update controls file (FHEM) | |
if: needs.pr_check.outputs.result != 'true' | |
uses: fhem/fhem-controls-actions@v2.3.0 | |
with: | |
filename: controls_signalduino.txt | |
- name: update controls file (lib) | |
if: needs.pr_check.outputs.result != 'true' | |
uses: fhem/fhem-controls-actions@v2.3.0 | |
with: | |
filename: controls_signalduino.txt | |
directory: FHEM/lib | |
writemode: a | |
- name: update CHANGED | |
if: steps.extract_branch.outputs.branch == 'master' | |
run: | | |
LOG=$(date +"%Y-%m-%d") | |
LOG+=" - $(git log -1 --pretty=%B)" | |
echo "$LOG" | cat - CHANGED > temp && mv temp CHANGED | |
- name: git commit back | |
if: needs.pr_check.outputs.result != 'true' | |
run: | | |
git config --global user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git ls-files --error-unmatch controls_signalduino.txt || git add controls_signalduino.txt | |
git ls-files --error-unmatch CHANGED || git add CHANGED | |
git diff --name-only --exit-code controls_signalduino.txt || git commit CHANGED controls_signalduino.txt -m "Automatic updated controls and CHANGED" || true | |
#- name: git push | |
# if: needs.pr_check.outputs.result != 'true' | |
# uses: ad-m/github-push-action@v0.6.0 | |
# with: | |
# github_token: ${{ secrets.GH_TOKEN }} | |
# branch: ${{ steps.extract_branch.outputs.branch }} | |
- name: Push to branch | |
uses: CasperWA/push-protected@v2 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
branch: ${{ steps.extract_branch.outputs.branch }} |