Skip to content

Linux64 / Linux armv6/armv7/arm64 - Configure build list #192

Linux64 / Linux armv6/armv7/arm64 - Configure build list

Linux64 / Linux armv6/armv7/arm64 - Configure build list #192

name: cleanup artifact caches keep latest
on:
push:
paths-ignore:
- '**/README.md'
pull_request:
paths-ignore:
- '**/README.md'
# on:
# pull_request:
# types:
# - closed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
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:
cleanup-artifacts:
runs-on: ubuntu-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Log old artifacts for potential deletion
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
uses: actions/[email protected]
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: 1000 // Get up to 1000 artifacts
});
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) {
// where name is: openFrameworksLibs_${{ env.RELEASE }}_${{ env.TARGET }}_${{ env.ARCH }}_${{ matrix.bundle }}.zip
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(`Would delete older artifact: ${artifact.name} (${artifact.created_at} | ${artifact.size_in_bytes} bytes)`);
//
/**
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 {
console.log(`Keeping artifact: ${artifact.name} (${artifact.created_at} | ${artifact.size_in_bytes} bytes)size_in_bytes`);
}
}