diff --git a/.github/workflows/outdated-update-package.yml b/.github/workflows/outdated-update-package.yml new file mode 100644 index 0000000..263adcc --- /dev/null +++ b/.github/workflows/outdated-update-package.yml @@ -0,0 +1,57 @@ +name: Update outdated package + +on: + workflow_dispatch: + inputs: + package_name: + required: true + type: string + package_version: + required: true + type: string + +jobs: + upgrade: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + persist-credentials: false + + - name: Install pip-tools + run: | + python -m venv venv + source venv/bin/activate + python -m pip install --upgrade pip pip-tools + + - name: Upgrade outdated package + env: + PACKAGE_NAME: ${{ github.event.inputs.package_name }} + PACKAGE_VERSION: ${{ github.event.inputs.package_version }} + run: | + source venv/bin/activate + + set -x + echo "Upgrading ${PACKAGE_NAME} to version ${PACKAGE_VERSION}" + upgrade_package="${PACKAGE_NAME}==${PACKAGE_VERSION}" + pip-compile \ + --upgrade-package="${upgrade_package}" \ + --output-file="scripts/make_release_requirements.txt" \ + "scripts/make_release_requirements.in" + + - name: Create or update pull request + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "Update package ${{ github.event.inputs.package_name }}" + labels: cleanup-no-release-required, dependencies, github_actions + title: ⬆ Update ${{ github.event.inputs.package_name }} + body: "Updating ${{ github.event.inputs.package_name }}" + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + branch: "create-pull-request/upgrade-${{ github.event.inputs.package_name }}-${{ github.run_id }}" + committer: GitHub + delete-branch: true + token: ${{ secrets.PHP_CURL_CLASS_BOT_TOKEN }} + push-to-fork: php-curl-class-helper/php-curl-class + env: + GITHUB_TOKEN: ${{ secrets.PHP_CURL_CLASS_BOT_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/outdated-update.yml b/.github/workflows/outdated-update.yml index b3c1c94..535584e 100644 --- a/.github/workflows/outdated-update.yml +++ b/.github/workflows/outdated-update.yml @@ -1,4 +1,4 @@ -name: Update outdated dependencies +name: Update outdated packages on: schedule: @@ -20,7 +20,7 @@ jobs: source venv/bin/activate python -m pip install --upgrade pip pip-tools - - name: Upgrade outdated dependencies + - name: Upgrade outdated packages run: | items=($( jq -r '.[1:]' "scripts/make_release_requirements.json" | @@ -31,7 +31,15 @@ jobs: echo "found outdated package:" echo "name: ${package_name}" echo "version: ${package_version}" - # TODO: Attempt to upgrade the package. + curl + --request "POST" \ + --silent \ + --header "Accept: application/vnd.github+json" \ + --header "Authorization: Bearer ${TOKEN}" \ + "https://api.github.com/repos/php-curl-class/php-curl-class/actions/workflows/outdated-update-package.yml/dispatches" \ + --data "{\"ref\":\"main\",\"inputs\":{\"package_name\":\"${package_name}\",\"package_version\":\"${package_version}\"}}" done - echo "done" \ No newline at end of file + echo "done" + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file