|
| 1 | +name: Fetch Latest CA File |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # This will run daily at 00:00 UTC. |
| 6 | + - cron: '0 0 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + fetch-ca-file: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Check out repository |
| 14 | + uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - name: Fetch the latest CA file |
| 17 | + run: | |
| 18 | + curl -O https://curl.se/ca/cacert.pem |
| 19 | + echo "Fetched the latest CA file." |
| 20 | +
|
| 21 | + - name: Check if the CA file has changed |
| 22 | + id: cafile |
| 23 | + run: | |
| 24 | + CHANGED=$(git diff --name-only | grep cacert.pem || true) |
| 25 | + if [[ ! -z "$CHANGED" ]]; then |
| 26 | + echo "::set-output name=changed::true" |
| 27 | + else |
| 28 | + echo "::set-output name=changed::false" |
| 29 | + fi |
| 30 | +
|
| 31 | + - name: Commit changes |
| 32 | + if: steps.cafile.outputs.changed == 'true' |
| 33 | + run: | |
| 34 | + git config --local user.email "[email protected]" |
| 35 | + git config --local user.name "Simon Hamp" |
| 36 | + git add cacert.pem |
| 37 | + git commit -m "Update CA file" |
| 38 | + git push |
| 39 | +
|
| 40 | + release: |
| 41 | + needs: fetch-ca-file |
| 42 | + if: needs.fetch-ca-file.outputs.changed == 'true' |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Get the latest release |
| 46 | + id: latestrelease |
| 47 | + run: | |
| 48 | + LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" \ |
| 49 | + | jq -r .tag_name) |
| 50 | + echo "::set-output name=version::${LATEST_VERSION}" |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Create a new release |
| 55 | + id: create_release |
| 56 | + uses: actions/create-release@v1 |
| 57 | + with: |
| 58 | + tag_name: ${{ steps.latestrelease.outputs.version }} |
| 59 | + release_name: Release ${{ steps.latestrelease.outputs.version }} |
| 60 | + draft: false |
| 61 | + prerelease: false |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments