write release information to file #37
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: write release information to file | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "tag: The tag to use for this release" | |
required: true | |
default: v0.1.0 | |
jobs: | |
release_info: | |
runs-on: ubuntu-latest | |
steps: | |
- id: info | |
uses: konveyor/move2kube-get-release-info@v1 | |
with: | |
owner: konveyor | |
repo: move2kube | |
token: ${{ secrets.MOVE2KUBE_PATOKEN }} | |
- uses: actions/checkout@v2 | |
- run: echo '${{ steps.info.outputs.release_info }}' > _data/releaseinfo.json | |
- id: get_asset_url | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.MOVE2KUBE_PATOKEN }} | |
script: | | |
const response = await github.repos.listReleases({ owner:context.repo.owner, repo:'move2kube-ui' }); | |
const releases = response.data.slice(); | |
releases.sort((x, y) => Date.parse(x.published_at) < Date.parse(y.published_at) ? 1 : -1); // sort in descending order | |
const latest_release = releases[0]; | |
const assets = latest_release.assets.filter(x => x.name === 'index.yaml'); | |
if(assets.length !== 1) { | |
return console.error(`Expected to find exactly one asset with the name index.yaml . Found: ${assets.length}`); | |
} | |
const asset = assets[0]; | |
core.setOutput('url', asset.url); | |
- run: | | |
curl -L -o index.yaml -H 'Authorization: token ${{ secrets.MOVE2KUBE_PATOKEN }}' -H 'Accept: application/octet-stream' ${{ steps.get_asset_url.outputs.url }} | |
- uses: EndBug/add-and-commit@v6 | |
with: | |
add: '["_data/releaseinfo.json", "index.yaml"]' | |
author_name: move2kube | |
author_email: [email protected] | |
branch: main | |
cwd: "." | |
message: "chore: update release information. run_id ${{ github.run_id }}" | |
pull_strategy: "--ff-only" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: trigger creation of a new homebrew formula | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.MOVE2KUBE_PATOKEN }} | |
script: | | |
const tag = '${{ github.event.inputs.tag }}'; | |
await github.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: 'homebrew-move2kube', | |
workflow_id: 'publish.yml', | |
ref: 'main', | |
inputs: {tag}, | |
}); |