emscripten 4.0.16 -> 5.0.5 #540
Workflow file for this run
This file contains hidden or 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: cleanup-artifacts | |
| on: | |
| push: | |
| paths-ignore: | |
| - '**/README.md' | |
| pull_request: | |
| types: | |
| - closed | |
| paths-ignore: | |
| - '**/README.md' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| env: | |
| TARGET: "vs" | |
| ARCH: arm64 | |
| NO_FORCE: 1 | |
| VS_VER: 17 | |
| GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
| GH_TOKEN: ${{ secrets.CI_SECRET }} | |
| USE_ARTIFACT: true | |
| jobs: | |
| pre-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Log old artifacts for potential deletion | |
| if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding') | |
| uses: actions/github-script@v7.0.1 | |
| env: | |
| GH_TOKEN: ${{ secrets.CI_SECRET }} | |
| REPO: ${{ github.repository }} | |
| GA_CI_SECRET: ${{ secrets.CI_SECRET }} | |
| BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge | |
| with: | |
| script: | | |
| console.log(`Token: ${process.env.GH_TOKEN ? "Present" : "Missing"}`); | |
| console.log(`GA_CI_SECRET: ${process.env.GA_CI_SECRET ? "Present" : "Missing"}`); | |
| const artifacts = await github.rest.actions.listArtifactsForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| per_page: 100 | |
| }); | |
| console.log(artifacts); | |
| const keepLatestArtifacts = artifacts.data.artifacts | |
| .filter(artifact => !artifact.expired) | |
| .reduce((acc, artifact) => { | |
| const nameParts = artifact.name.split('-'); | |
| const release = nameParts[1]; | |
| const platform = nameParts[2]; // e.g., ios, macos, catos, xros, tvos | |
| const arch = nameParts[3]; // e.g., arm64, x86_64, etc. | |
| const bundle = nameParts[4]; // e.g., 1, 2, 3 | |
| const type = `${release}-${platform}-${arch}-${bundle}`; | |
| if (!acc[type] || acc[type].created_at < artifact.created_at) { | |
| acc[type] = artifact; | |
| } | |
| return acc; | |
| }, {}); | |
| for (const artifact of artifacts.data.artifacts) { | |
| const nameParts = artifact.name.split('-'); | |
| const release = nameParts[1]; | |
| const platform = nameParts[2]; | |
| const arch = nameParts[3]; | |
| const bundle = nameParts[4]; | |
| const type = `${release}-${platform}-${arch}-${bundle}`; | |
| if (!artifact.expired && keepLatestArtifacts[type].id !== artifact.id) { | |
| console.log(`DISABLED - WOULD delete older artifact: ${artifact.name} (${artifact.created_at} | ${artifact.size_in_bytes} bytes)`); | |
| // Uncomment the next lines to actually delete old artifacts | |
| /* | |
| await github.rest.actions.deleteArtifact({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| artifact_id: artifact.id | |
| }); | |
| */ | |
| console.log(`Deleted older artifact: ${artifact.name} (${artifact.created_at} | ${artifact.size_in_bytes} bytes)`); | |
| } else if (/^v\d+/i.test(release)) { | |
| console.log(`DISABLED - WOULD: Deleting artifact with "v*" in release: ${artifact.name} (${artifact.created_at} | ${artifact.size_in_bytes} bytes)`); | |
| // Uncomment to enable artifact deletion | |
| /* | |
| await github.rest.actions.deleteArtifact({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| artifact_id: artifact.id | |
| }); | |
| */ | |
| console.log(`Deleted artifact with "v*": ${artifact.name}`); | |
| } else { | |
| console.log(`Keeping artifact: ${artifact.name} (${artifact.created_at} | ${artifact.size_in_bytes} bytes)`); | |
| } | |
| } |