-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fabian Grutschus
committed
Dec 19, 2023
1 parent
c8369b6
commit b42646d
Showing
2 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: Auto Update | ||
|
||
on: | ||
schedule: | ||
- cron: "0 7 * * *" | ||
|
||
jobs: | ||
auto-update: | ||
name: "Auto-Update Rewinged Docker Image" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
env: | ||
JSONPATH_ALPINE: .jobs.docker-image-alpine.strategy.matrix.version | ||
REMOTE_GITHUB_REPO: pdepend/pdepend | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.WORKFLOW_TOKEN }} | ||
|
||
- name: Get lastest version from Github | ||
uses: octokit/request-action@v2.x | ||
id: pdepend_latest_release | ||
with: | ||
route: GET /repos/${{ env.REMOTE_GITHUB_REPO }}/releases/latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} | ||
|
||
- name: "Get OUR lastest version for Alpine" | ||
id: get_alpine_latest_version | ||
uses: mikefarah/yq@master | ||
with: | ||
cmd: yq '${{ env.JSONPATH_ALPINE }}.[-1].pdepend' '.github/workflows/docker.yml' | ||
|
||
- name: Set Environment | ||
run: | | ||
echo '${{ steps.pdepend_latest_release.outputs.data }}' > latest_release.json | ||
echo "PDEPEND_LATEST=$(echo '${{ fromJson(steps.pdepend_latest_release.outputs.data).tag_name }}')" >> $GITHUB_ENV | ||
echo "PDEPEND_VERSION_MAJOR=$(echo '${{ fromJson(steps.pdepend_latest_release.outputs.data).tag_name }}' | cut -d '.' -f1)" >> $GITHUB_ENV | ||
echo "PDEPEND_VERSION_MINOR=$(echo '${{ fromJson(steps.pdepend_latest_release.outputs.data).tag_name }}' | cut -d '.' -f1-2)" >> $GITHUB_ENV | ||
echo "PDEPEND_VERSION_ALPINE=${{ steps.get_alpine_latest_version.outputs.result }}" >> $GITHUB_ENV | ||
- name: Get Download URL | ||
id: get_download_url | ||
uses: mikefarah/yq@master | ||
with: | ||
cmd: yq -oy '.assets[] | select(.name == "pdepend.phar") | .browser_download_url' 'latest_release.json' | ||
|
||
- name: Download PHAR | ||
run: | | ||
curl -v -L '${{ steps.get_download_url.outputs.result }}' -o 'pdepend.phar' | ||
echo "PDEPEND_PHAR_HASH=$( sha256sum pdepend.phar | cut -d ' ' -f1 )" >> $GITHUB_ENV | ||
rm -f latest_release.json | ||
- run: | | ||
echo Latest Version: $PDEPEND_LATEST | ||
echo Major version: $PDEPEND_VERSION_MAJOR | ||
echo Minor version: $PDEPEND_VERSION_MINOR | ||
echo Our Alpine Version: $PDEPEND_VERSION_ALPINE | ||
echo Download Hash PHAR: $PDEPEND_PHAR_HASH | ||
- name: Handle version < 1 | ||
if: ${{ env.PDEPEND_VERSION_MAJOR == '0' }} | ||
run: | | ||
echo PDEPEND_VERSION_MAJOR="" >> $GITHUB_ENV | ||
echo PDEPEND_VERSION_MINOR="" >> $GITHUB_ENV | ||
- name: Fix Major versions Alpine | ||
if: ${{ env.PDEPEND_LATEST != env.PDEPEND_VERSION_ALPINE }} | ||
uses: mikefarah/yq@master | ||
with: | ||
cmd: | | ||
yq -i 'with((${{ env.JSONPATH_ALPINE }}[] | select(.pdepend_major == "${{ env.PDEPEND_VERSION_MAJOR }}")); .pdepend_major = "")' .github/workflows/docker.yml | ||
- name: Fix Minor versions Alpine | ||
if: ${{ env.PDEPEND_LATEST != env.PDEPEND_VERSION_ALPINE }} | ||
uses: mikefarah/yq@master | ||
with: | ||
cmd: | | ||
yq -i 'with((${{ env.JSONPATH_ALPINE }}[] | select(.pdepend_minor == "${{ env.PDEPEND_VERSION_MINOR }}")); .pdepend_minor = "")' .github/workflows/docker.yml | ||
- name: Fix Latest Alpine | ||
if: ${{ env.PDEPEND_LATEST != env.PDEPEND_VERSION_ALPINE }} | ||
uses: mikefarah/yq@master | ||
with: | ||
cmd: | | ||
yq -i 'with((${{ env.JSONPATH_ALPINE }}[] | select(.latest == true)); .latest = false)' .github/workflows/docker.yml | ||
- name: "Add new Version for Alpine" | ||
if: ${{ env.PDEPEND_LATEST != env.PDEPEND_VERSION_ALPINE }} | ||
uses: mikefarah/yq@master | ||
with: | ||
cmd: | | ||
yq -i '${{ env.JSONPATH_ALPINE }} = ${{ env.JSONPATH_ALPINE }} + {"pdepend": "${{ env.PDEPEND_LATEST }}", "pdepend_major": "${{ env.PDEPEND_VERSION_MAJOR }}", "pdepend_minor": "${{ env.PDEPEND_VERSION_MINOR }}", "sha256": "${{ env.PDEPEND_PHAR_HASH }}", "latest": true}' .github/workflows/docker.yml | ||
- name: Create Pull Request | ||
if: ${{ env.PDEPEND_LATEST != env.PDEPEND_VERSION_ALPINE }} | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: | | ||
git switch -c "update-${{ env.PDEPEND_LATEST }}" | ||
git config --global user.name "github-actions" | ||
git config --global user.email \ | ||
"41898282+github-actions[bot]@users.noreply.github.com" | ||
git add .github/workflows/docker.yml | ||
git commit --message "Version ${{ env.PDEPEND_LATEST }}" | ||
git push --set-upstream origin "update-${{ env.PDEPEND_LATEST }}" | ||
gh pr create --title "Version ${{ env.PDEPEND_LATEST }}" --body '' |
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