Skip to content

Commit

Permalink
restructure ci to not rebuild when nothing changed
Browse files Browse the repository at this point in the history
  • Loading branch information
programminghoch10 committed Oct 16, 2024
1 parent 67988b2 commit 5dda7bb
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 67 deletions.
60 changes: 60 additions & 0 deletions .github/actions/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: deploy

inputs:
branch:
required: true
type: string

runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: deploy
fetch-depth: 0

- name: Setup git
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
name: ${{ matrix.branch }}

- name: Copy artifacts
run: |
mv -f artifacts/app-release.apk ${{ matrix.branch }}/app-release.apk
mv -f artifacts/app-debug.apk ${{ matrix.branch }}/app-debug.apk
mv -f artifacts/stub-release.apk ${{ matrix.branch }}/stub-release.apk
rm -r artifacts
- name: Run helper script
run: |
git checkout origin/ci-management releasehelper.sh
chmod +x releasehelper.sh
./releasehelper.sh ${{ matrix.branch }}
mv -f ${{ matrix.branch }}.json docs
mv -f note.md ${{ matrix.branch }}/note.md
rm releasehelper.sh
- name: Commit update
run: |
git restore --staged .
git add ${{ matrix.branch }}/app-release.apk
git add ${{ matrix.branch }}/app-debug.apk
git add ${{ matrix.branch }}/stub-release.apk
git add ${{ matrix.branch }}/note.md
git add docs/${{ matrix.branch }}.json
git commit --amend -m "Update ${{ matrix.branch }} ${{ env.VERSION }}"
- name: Push result
uses: ad-m/[email protected]
with:
branch: deploy
force_with_lease: true
github_token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
5 changes: 5 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ on:
branch:
required: true
type: string
outputs:
changed:
value: ${{ jobs.automerge.outputs.changed }}

jobs:
automerge:
name: Automerge ${{ inputs.branch }}
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.rebase.outputs.changed }}

steps:
- name: Checkout
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
branch: madness
build-stable:
needs: automerge-stable
if: needs.automerge-stable.outputs.changed == 'true'
uses: ./.github/workflows/build.yml
with:
branch: stable
Expand All @@ -36,6 +37,7 @@ jobs:
KEYSTORE_KEY: ${{ secrets.KEYSTORE_KEY }}
build-beta:
needs: automerge-beta
if: needs.automerge-beta.outputs.changed == 'true'
uses: ./.github/workflows/build.yml
with:
branch: beta
Expand All @@ -44,6 +46,7 @@ jobs:
KEYSTORE_KEY: ${{ secrets.KEYSTORE_KEY }}
build-canary:
needs: automerge-canary
if: needs.automerge-canary.outputs.changed == 'true'
uses: ./.github/workflows/build.yml
with:
branch: canary
Expand All @@ -52,6 +55,7 @@ jobs:
KEYSTORE_KEY: ${{ secrets.KEYSTORE_KEY }}
build-madness:
needs: automerge-madness
if: needs.automerge-madness.outputs.changed == 'true'
uses: ./.github/workflows/build.yml
with:
branch: madness
Expand All @@ -61,4 +65,15 @@ jobs:
deploy:
if: always()
needs: [build-stable, build-beta, build-canary, build-madness]
uses: ./.github/workflows/deploy.yml
runs-on: ubuntu-latest
strategy:
matrix:
branch: [ stable, beta, canary, madness ]
fail-fast: false
max-parallel: 1
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/deploy.yml
if: needs[format('build-{0}', matrix.branch)].outputs.changed == 'true'
with:
branch: ${{ matrix.branch }}
66 changes: 0 additions & 66 deletions .github/workflows/deploy.yml

This file was deleted.

0 comments on commit 5dda7bb

Please sign in to comment.