Create Pull Request of SimpleSAMLphp new version #1693
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: Create Pull Request of SimpleSAMLphp new version | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
env: | |
PULL_REQUEST_BRANCH_PREFIX: create-pull-request/simplesamlphp- | |
jobs: | |
check-latest-version: | |
runs-on: ubuntu-latest | |
outputs: | |
is-continued-pr: ${{ steps.check-latest-version.outputs.update == 'required' && steps.check-pull-request.outputs.pr == 'required' }} | |
simplesamlphp-latest: ${{ steps.simplesamlphp-latest.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oprypin/find-latest-tag@v1 | |
with: | |
repository: simplesamlphp/simplesamlphp | |
releases-only: true | |
id: simplesamlphp-latest | |
- name: Get current simplesamlphp version | |
run: | | |
echo "::set-output name=version::$( cat .simplesamlphp_version )" | |
id: simplesamlphp-current | |
- name: Echo simplesamlphp versions | |
run: | | |
echo "The latest simplesamlphp version is ${{ steps.simplesamlphp-latest.outputs.tag }}" | |
echo "The current simplesamlphp version is ${{ steps.simplesamlphp-current.outputs.version }}" | |
- name: Check latest version | |
id: check-latest-version | |
run: | | |
latest=$(echo "${{ steps.simplesamlphp-latest.outputs.tag }}" | tr -d 'v.') | |
current=$(echo "${{ steps.simplesamlphp-current.outputs.version }}" | tr -d 'v.') | |
if [[ "${latest}" -lt "${current}" ]]; then | |
echo "${{ steps.simplesamlphp-latest.outputs.tag }} may be already exist." | |
echo "::set-output name=update::none" | |
else | |
echo "::set-output name=update::required" | |
fi | |
- name: Check current pull request | |
id: check-pull-request | |
run: | | |
branch_name="${{ env.PULL_REQUEST_BRANCH_PREFIX }}${{ steps.simplesamlphp-latest.outputs.tag }}" | |
remote_url=$( git config --get remote.origin.url ) | |
has_branch=$( git ls-remote --heads "${remote_url}" "${branch_name}" ) | |
if [[ "${has_branch}" ]]; then | |
echo "${branch_name} branch is already exist." | |
echo "::set-output name=pr::none" | |
else | |
echo "::set-output name=pr::required" | |
fi | |
create-pull-request: | |
needs: check-latest-version | |
runs-on: ubuntu-latest | |
if: needs.check-latest-version.outputs.is-continued-pr == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Update current version file | |
run: | | |
version=$(echo "${{ needs.check-latest-version.outputs.simplesamlphp-latest }}" | tr -d 'v') | |
echo "${version}" > .simplesamlphp_version | |
sed -i -e "s/\(SIMPLESAMLPHP_VERSION\):.\+/\1: \"${version}\"/g" docker-compose.yml | |
- name: Git status | |
run: | | |
git status | |
- name: Git diff | |
run: | | |
git diff | |
- name: Create Pull Request | |
uses: peter-evans/[email protected] | |
id: create-pull-request | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
title: Bump simplesamlphp version to ${{ needs.check-latest-version.outputs.simplesamlphp-latest }} | |
body: | | |
This is an automated PR to update the [simplesamlphp](https://github.com/simplesamlphp/simplesamlphp). | |
- Check if there is any omission between [${{ needs.check-latest-version.outputs.simplesamlphp-latest }}](https://github.com/simplesamlphp/simplesamlphp/releases/tag/${{ needs.check-latest-version.outputs.simplesamlphp-latest }}) and the existing version. | |
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request) | |
branch: ${{ env.PULL_REQUEST_BRANCH_PREFIX }}${{ needs.check-latest-version.outputs.simplesamlphp-latest }} | |
base: master | |
labels: automated pr | |
- name: Check outputs | |
run: | | |
echo "Created a pull request - ${{ steps.create-pull-request.outputs.pull-request-url }}" |