Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/packagist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Packagist

# Packagist only learns about new commits and tags right away from a hook; without one it
# crawls the repository about once a week, so `composer require validator/livr` keeps
# installing old code. This workflow tells Packagist about every push to master and every tag.
#
# Needs two repository secrets: PACKAGIST_USERNAME, a maintainer of validator/livr on
# packagist.org, and PACKAGIST_TOKEN, their safe API token from https://packagist.org/profile/.

on:
push:
branches: [ master ]
tags: [ '*' ]
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Update the package on Packagist
env:
PACKAGIST_USERNAME: ${{ secrets.PACKAGIST_USERNAME }}
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}
REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
if [ -z "$PACKAGIST_USERNAME" ] || [ -z "$PACKAGIST_TOKEN" ]; then
echo "::warning::PACKAGIST_USERNAME and PACKAGIST_TOKEN are not set, so Packagist only sees this push on its weekly crawl"
exit 0
fi
curl -fsS --retry 3 -X POST https://packagist.org/api/update-package \
-H 'content-type: application/json' \
-H "authorization: Bearer $PACKAGIST_USERNAME:$PACKAGIST_TOKEN" \
-d "{\"repository\":\"$REPOSITORY_URL\"}"
Loading