11name : 3. Create Certificates
22run-name : Create Certificates (${{ github.ref_name }})
3- on :
4- workflow_dispatch :
3+
4+ on : [workflow_call, workflow_dispatch]
5+
6+ env :
7+ TEAMID : ${{ secrets.TEAMID }}
8+ GH_PAT : ${{ secrets.GH_PAT }}
9+ GH_TOKEN : ${{ secrets.GH_PAT }}
10+ MATCH_PASSWORD : ${{ secrets.MATCH_PASSWORD }}
11+ FASTLANE_KEY_ID : ${{ secrets.FASTLANE_KEY_ID }}
12+ FASTLANE_ISSUER_ID : ${{ secrets.FASTLANE_ISSUER_ID }}
13+ FASTLANE_KEY : ${{ secrets.FASTLANE_KEY }}
514
615jobs :
716 validate :
817 name : Validate
918 uses : ./.github/workflows/validate_secrets.yml
1019 secrets : inherit
1120
12- certificates :
13- name : Create Certificates
21+ create_certs :
22+ name : Certificates
1423 needs : validate
1524 runs-on : macos-15
1625 outputs :
1726 new_certificate_needed : ${{ steps.set_output.outputs.new_certificate_needed }}
1827 steps :
1928 - name : Checkout Repo
2029 uses : actions/checkout@v4
21-
30+
2231 - name : Patch Match Tables
23- run : find /usr/local/lib/ruby/gems -name table_printer.rb | xargs sed -i "" "/puts(Terminal::Table.new(params))/d"
24-
25- - name : Sync clock
26- run : sudo sntp -sS time.windows.com
32+ run : |
33+ TABLE_PRINTER_PATH=$(ruby -e 'puts Gem::Specification.find_by_name("fastlane").gem_dir')/match/lib/match/table_printer.rb
34+ if [ -f "$TABLE_PRINTER_PATH" ]; then
35+ sed -i "" "/puts(Terminal::Table.new(params))/d" "$TABLE_PRINTER_PATH"
36+ else
37+ echo "table_printer.rb not found"
38+ exit 1
39+ fi
40+
41+ - name : Install Project Dependencies
42+ run : bundle install
2743
2844 - name : Run Fastlane certs lane
2945 run : |
3046 echo "Running Fastlane certs lane..."
31- bundle exec fastlane certs || true # ignore errors to continue with check
32-
47+ bundle exec fastlane certs || true
48+
3349 - name : Check Distribution certificate and renew if needed
3450 run : bundle exec fastlane check_and_renew_certificates
3551 id : check_certs
36-
37- - name : Set output based on certificate status
52+
53+ - name : Set output and annotations based on Fastlane result
3854 id : set_output
3955 run : |
4056 CERT_STATUS_FILE="${{ github.workspace }}/fastlane/new_certificate_needed.txt"
@@ -48,47 +64,46 @@ jobs:
4864 echo "Certificate status file not found. Defaulting to false."
4965 echo "new_certificate_needed=false" >> $GITHUB_OUTPUT
5066 fi
51-
52- # Warn if certificate renewal is disabled in the repo variables
67+
5368 if [ "$CERT_STATUS" != "true" ] && [ "$ENABLE_NUKE_CERTS" != "true" ]; then
5469 echo "::notice::🔔 Automated renewal of certificates is disabled because ENABLE_NUKE_CERTS is not set to 'true'."
5570 fi
56-
71+
5772 if [ "$CERT_STATUS" = "true" ] && [ "$ENABLE_NUKE_CERTS" != "true" ]; then
58- echo "::error::❌ No valid distribution certificate found. Automated renewal was skipped because ENABLE_NUKE_CERTS is not 'true'."
73+ echo "::error::❌ No valid distribution certificate found. Automated renewal of certificates was skipped because ENABLE_NUKE_CERTS is not set to 'true'."
5974 exit 1
6075 fi
61-
76+
6277 if [ "${{ vars.FORCE_NUKE_CERTS }}" = "true" ]; then
6378 echo "::warning::‼️ Nuking of certificates was forced because FORCE_NUKE_CERTS is set to 'true'."
6479 fi
6580
6681 nuke_certs :
6782 name : Nuke certificates
68- needs : [validate, certificates ]
83+ needs : [validate, create_certs ]
6984 runs-on : macos-14
70- if : ${{ (needs.certificates .outputs.new_certificate_needed == 'true' && vars.ENABLE_NUKE_CERTS == 'true') || vars.FORCE_NUKE_CERTS == 'true' }}
85+ if : ${{ (needs.create_certs .outputs.new_certificate_needed == 'true' && vars.ENABLE_NUKE_CERTS == 'true') || vars.FORCE_NUKE_CERTS == 'true' }}
7186 steps :
72- - name : Show certificate check output
73- run : echo "new_certificate_needed=${{ needs.certificates .outputs.new_certificate_needed }}"
74-
87+ - name : Output from step id 'check_certs'
88+ run : echo "new_certificate_needed=${{ needs.create_certs .outputs.new_certificate_needed }}"
89+
7590 - name : Checkout repository
7691 uses : actions/checkout@v4
77-
92+
7893 - name : Install dependencies
7994 run : bundle install
80-
95+
8196 - name : Run Fastlane nuke_certs
8297 run : |
8398 set -e
8499 bundle exec fastlane nuke_certs
85-
100+
86101 - name : Recreate Distribution certificate after nuking
87102 run : |
88103 set -e
89104 bundle exec fastlane certs
90-
91- - name : Add success annotations
105+
106+ - name : Add success annotations for nuke and certificate recreation
92107 if : ${{ success() }}
93108 run : |
94109 echo "::warning::⚠️ All Distribution certificates and TestFlight profiles have been revoked and recreated."
0 commit comments