Auto Release #7
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: Auto Release | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
check_releases: | |
name: Check for Missing Releases | |
runs-on: ubuntu-latest | |
outputs: | |
missing_tags: ${{ steps.filter_tags.outputs.result }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Xanmod tags | |
id: get_xanmod_tags | |
run: | | |
echo "::set-output name=xanmod_tags::\"$(curl 'https://gitlab.com/api/v4/projects/xanmod%2Flinux/releases?per_page=100&order_by=created_at&sort=desc' -sL | jq 'map(.tag_name)')\"" | |
- name: Get Existing GitHub Tags | |
id: get_github_tags | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const tags = await github.rest.repos.listTags({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
per_page: 100, | |
}); | |
return tags.data.map(tag => tag.name); | |
- name: Filter Missing Tags | |
id: filter_tags | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { xanmod_tags, github_tags } = process.env | |
const xanmodTags = JSON.parse(`${xanmod_tags}`); | |
const githubTags = JSON.parse(`${github_tags}`); | |
const missingTags = xanmodTags | |
.map(release => release.replace(/-xanmod1$/, '')) | |
.filter(tag => !githubTags.includes(tag)); | |
return missingTags; | |
env: | |
xanmod_tags: ${{ steps.get_xanmod_tags.outputs.xanmod_tags }} | |
github_tags: ${{ steps.get_github_tags.outputs.result }} | |
build_missing_releases: | |
name: Build Missing Releases | |
needs: check_releases | |
runs-on: ubuntu-latest | |
if: ${{ needs.check_releases.outputs.missing_tags != '[]' }} | |
strategy: | |
matrix: | |
tag: ${{ fromJson(needs.check_releases.outputs.missing_tags) }} | |
steps: | |
- name: Trigger Release Workflow | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
await github.rest.repos.createDispatchEvent({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
event_type: 'release-event', | |
client_payload: { | |
version: '${{ matrix.tag }}' | |
} | |
}); |