set OtaCrcInitializer to OTA_VERSION_ID during binding (#2983)
[ExpressLRS.git] / .github / workflows / artifacts.yml
blob13ab0e81cf2b84f2c47bdc0d1ed6a9aef56f21d3
1 name: Cleanup stale artifacts
2 on:
3   schedule:
4     - cron: "30 2 * * *"
6 jobs:
7   cleanup-artifacts:
8     runs-on: ubuntu-latest
9     steps:
10       - name: Checkout code
11         uses: actions/checkout@v4
12         with:
13           fetch-depth: 0
15       - name: Remove stale artifacts from R2
16         env:
17           AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
18           AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
19           AWS_ENDPOINT_URL: ${{ secrets.AWS_ENDPOINT_URL }}
20           AWS_REGION: "auto"
21         run: |
22           if [[ -z $AWS_ACCESS_KEY_ID || -z $AWS_SECRET_ACCESS_KEY || -z $AWS_ENDPOINT_URL ]]; then
23             echo "Artifactory credentials are not defined. Most likely action is running from pull request. Not a bug."
24             exit 0
25           fi
27           echo "Generating artifact index"
28           aws s3 ls --endpoint-url $AWS_ENDPOINT_URL s3://expresslrs/ExpressLRS/ | grep PRE | awk '{print $2}' | sed s/\\/// > /tmp/artifacts
30           git branch --list --remotes --format '%(objectname)' > /tmp/hashes
31           git tag --list --format '%(objectname)' >> /tmp/hashes
33           for i in `grep -v -f /tmp/hashes /tmp/artifacts`; do
34             aws s3 rm --recursive --endpoint-url $AWS_ENDPOINT_URL s3://expresslrs/ExpressLRS/$i
35           done