Gaia Linux Build Main #2693
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: Gaia Linux Build Main | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 6,8,10,12,14,16,18 * * 1-5' | |
# push: | |
jobs: | |
collect_remote_commit: | |
name: Read latest main branch commit | |
runs-on: ubuntu-latest | |
outputs: | |
sha: ${{ steps.query_commit.outputs.sha }} | |
steps: | |
- name: Query latest commit on the main branch | |
id: query_commit | |
run: | | |
commit=$(curl -s -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/cosmos/gaia/branches/main | jq -r '.commit.sha') | |
echo "sha=$commit" >> "$GITHUB_OUTPUT" | |
collect_latest_build: | |
name: Read latest release from build repo | |
runs-on: ubuntu-latest | |
outputs: | |
sha: ${{ steps.query_release.outputs.sha }} | |
steps: | |
- name: Query latest release | |
id: query_release | |
run: | | |
curl -s -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/hyphacoop/cosmos-builds/releases\?per_page\=50 > releases.json | |
release=$(jq -r '.[] | select(.tag_name == "gaiad-linux-main") | .name' releases.json) | |
echo "sha=$release" >> "$GITHUB_OUTPUT" | |
build-binary: | |
name: Build binary | |
runs-on: ubuntu-latest | |
needs: [collect_remote_commit, collect_latest_build] | |
if: needs.collect_remote_commit.outputs.sha != needs.collect_latest_build.outputs.sha | |
permissions: | |
contents: write | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v3 | |
- name: Remove old releases | |
uses: dev-drprasad/[email protected] | |
with: | |
keep_latest: 0 | |
delete_tag_pattern: "gaiad-linux-main" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and release | |
uses: ./.github/actions/build-gaiad-binary | |
with: | |
ref: main | |
release_name: gaiad-linux-main | |
remote_commit_sha: ${{ needs.collect_remote_commit.outputs.sha }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
bot_token: ${{ secrets.HYPHA_BOT_ACTIONS_TOKEN }} | |
build-docker: | |
name: Build Docker image | |
runs-on: ubuntu-latest | |
needs: [collect_remote_commit, collect_latest_build] | |
if: needs.collect_remote_commit.outputs.sha != needs.collect_latest_build.outputs.sha | |
permissions: write-all | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Delete old docker images | |
uses: rafalkk/remove-dockertag-action@v1 | |
continue-on-error: true | |
with: | |
tag_name: hyphacoop/gaia:main | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Retag | |
run: | | |
docker pull "ghcr.io/cosmos/gaia:main" | |
docker tag "ghcr.io/cosmos/gaia:main" "ghcr.io/hyphacoop/gaia:main" | |
docker push "ghcr.io/hyphacoop/gaia:main" |