10.0.0 #15
Workflow file for this run
This file contains hidden or 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: Check Packagist Publish | |
on: | |
release: | |
types: [published] | |
jobs: | |
check-publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
repository: XeroAPI/xero-php-oauth2 | |
path: xero-php-oauth2 | |
- name: Fetch Latest release number | |
id: get_latest_release_number | |
run: | | |
latest_version=$(gh release view --json tagName --jq '.tagName') | |
echo "Latest release version is - $latest_version" | |
echo "php_version=${latest_version}" >> $GITHUB_ENV | |
working-directory: xero-php-oauth2 | |
env: | |
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- name: Get latest version from packgist | |
id: get_packagist_version | |
run: | | |
RESPONSE=$(curl -s https://repo.packagist.org/p2/xeroapi/xero-php-oauth2.json) | |
LATEST_VERSION=$(echo $RESPONSE | jq -r '.packages["xeroapi/xero-php-oauth2"][0].version') | |
echo "latest packagist version: $LATEST_VERSION" | |
echo "latest_packagist_version=${LATEST_VERSION}" >> $GITHUB_ENV | |
- name: Compare versions | |
id: compare_versions | |
run: | | |
if [ "${{env.php_version}}" == "${{env.latest_packagist_version}}" ]; then | |
echo "Packagist is up-to-date" | |
echo "packagist_status=success" >> $GITHUB_ENV | |
else | |
echo "Packagist is not updated yet" | |
echo "packagist_status=failure" >> $GITHUB_ENV | |
fi | |
- name: Send slack Notification on Success | |
if: ${{ env.packagist_status == 'success' }} | |
uses: ./xero-php-oauth2/.github/actions/notify-slack | |
with: | |
heading_text: "Publish job has succeeded !" | |
alert_type: "thumbsup" | |
job_status: "Success" | |
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} | |
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" | |
button_type: "primary" | |
package_version: ${{env.php_version}} | |
repo_link: ${{github.server_url}}/${{github.repository}} | |
- name: Send slack Notification on Failure | |
if: ${{ env.packagist_status == 'failure' }} | |
uses: ./xero-php-oauth2/.github/actions/notify-slack | |
with: | |
heading_text: "Publish job has failed !" | |
alert_type: "alert" | |
job_status: "Failed" | |
XERO_SLACK_WEBHOOK_URL: ${{secrets.XERO_SLACK_WEBHOOK_URL}} | |
job_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" | |
button_type: "danger" | |
package_version: ${{env.php_version}} | |
repo_link: ${{github.server_url}}/${{github.repository}} | |
- name: Fail job if status is Failure | |
if: ${{env.packagist_status == 'failure'}} | |
run: | | |
echo "Job failed because packagist is not updated" | |
exit 1 |