Skip to content

Commit

Permalink
Fix check_certs.yml and Fastfile, get outputs from fastlane if cert_…
Browse files Browse the repository at this point in the history
…revoked is true
  • Loading branch information
bjornoleh committed Jan 7, 2025
1 parent f33c006 commit b16845e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/check_certs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
jobs:
check_certs:
runs-on: ubuntu-latest
outputs:
cert_revoked: ${{ steps.set_output.outputs.cert_revoked }} # Job-level output

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -24,8 +27,14 @@ jobs:
FASTLANE_USER: ${{ secrets.APPLE_ID }}
FASTLANE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
run: fastlane check_and_revoke_certificates
id: check_certs

- name: Set output based on Fastlane result
id: set_output
run: echo "::set-output name=cert_revoked::$(cat cert_revoked.txt)" # Output from Fastlane saved to a file

trigger_create_certs:
needs: check_certs
if: env.cert_revoked == 'true'
if: ${{ needs.check_certs.outputs.cert_revoked == 'true' }}
uses: ./.github/workflows/create_certs.yml

6 changes: 3 additions & 3 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,17 @@ platform :ios do

if expiration_date < Time.now + 30 * 24 * 60 * 60 # Less than 30 days to expiry
puts "Certificate #{cert.id} is expiring soon or already expired. Revoking..."
#cert.revoke!
cert.revoke!
revoked = true
end
end

if revoked
puts "Certificates were revoked. Triggering workflow to recreate them."
Actions.sh("echo 'cert_revoked=true' >> $GITHUB_ENV") # Set GitHub Actions environment variable
File.write('cert_revoked.txt', 'true')
else
puts "All certificates are valid. No action required."
Actions.sh("echo 'cert_revoked=false' >> $GITHUB_ENV") # Set GitHub Actions environment variable
File.write('cert_revoked.txt', 'false')
end
end
end

0 comments on commit b16845e

Please sign in to comment.