Skip to content

Add note on ARM to README #9

Add note on ARM to README

Add note on ARM to README #9

Workflow file for this run

# workflows to sync certain files when changes are pushed to the main branch
name: Sync
on:
push:
branches:
- 'main'
paths:
- 'README.md'
pull_request_target:
branches:
- 'main'
paths:
- 'config/crd/bases/**.yaml'
- 'charts/aws-pca-issuer/crds/**.yaml'
env:
GITHUB_USER_NAME: github-actions
GITHUB_USER_EMAIL: [email protected]
GH_PAGES_BRANCH: gh-pages
CONFIG_DIR: config/crd/bases
CHARTS_DIR: charts/aws-pca-issuer/crds
jobs:
sync-readme:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ env.GH_PAGES_BRANCH }}
- name: Push README to gh-pages branch
run: |
git config user.name "$GITHUB_USER_NAME"
git config user.email "$GITHUB_USER_EMAIL"
git fetch -a
git checkout $GITHUB_SHA -- README.md
mv README.md index.md
git add index.md README.md
if git commit -m "Sync readme from commit $GITHUB_SHA" --signoff; then
git push origin $GH_PAGES_BRANCH
else
echo "Nothing committed, not pushing."
fi
sync-crds:
if: ${{ github.event_name == 'pull_request_target' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
- name: Check which CRDs are modified
id: which-crd-modified
run: |
URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }}/files"
FILES=$(curl -s -X GET -G $URL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | jq -r '.[] | .filename')
# Check if CRDs are modified in charts or config or both.
# Unfortunately we cannot overwrite contributor's changes
# using the update-pull-request-action, so if
# both CRDs are changed and not equal, we fail the workflow
# and post a comment on the PR informing the contributor
# that the CRDs must be identical.
changed_config=$( (echo $FILES | grep -q -E "${CONFIG_DIR}/[[:graph:]]*\.yaml" && echo true) || echo false )
changed_charts=$( (echo $FILES | grep -q -E "${CHARTS_DIR}/[[:graph:]]*\.yaml" && echo true) || echo false )
if $changed_config && ! $changed_charts; then
echo "result=config" >> $GITHUB_OUTPUT
elif $changed_charts && ! $changed_config; then
echo "result=charts" >> $GITHUB_OUTPUT
else
echo "result=both" >> $GITHUB_OUTPUT
fi
- name: Copy changed config CRDs to chart
if: ${{ steps.which-crd-modified.outputs.result == 'config' && !github.event.pull_request.head.repo.fork }}
run: |
cp ${CONFIG_DIR}/*.yaml ${CHARTS_DIR}
- name: Copy changed chart CRDs to config
if: ${{ steps.which-crd-modified.outputs.result == 'charts' && !github.event.pull_request.head.repo.fork }}
run: |
cp ${CHARTS_DIR}/*.yaml ${CONFIG_DIR}
- name: Verify both CRDs are the same
if: ${{ steps.which-crd-modified.outputs.result == 'both' || github.event.pull_request.head.repo.fork }}
run: |
for config_file in $CONFIG_DIR/*.yaml; do
chart_file=$CHARTS_DIR/$(basename $config_file)
if ! diff $config_file $chart_file; then
echo "${config_file} and ${chart_file} are different"
exit 1
fi
done
- name: Update pull request with synced CRDs
if: ${{ steps.which-crd-modified.outputs.result != 'both' && !github.event.pull_request.head.repo.fork }}
uses: divyansh-gupta/create-or-update-pull-request-action@65a6b01b19b69d7865fcf484340b06548fc02e64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: ${{ github.head_ref }}
path: "."
commit-message: |
Sync CRDs in pull-request ${{ github.event.pull_request.number }}
Signed-off-by: ${{ env.GITHUB_USER_NAME }} <${{ env.GITHUB_USER_EMAIL }}>
author: "${{ env.GITHUB_USER_NAME }} <${{ env.GITHUB_USER_EMAIL }}>"
- name: Comment on pull request that CRDs were synced
if: ${{ steps.which-crd-modified.outputs.result != 'both' && !github.event.pull_request.head.repo.fork }}
uses: divyansh-gupta/actions-comment-pull-request@675cdfe1695d33e816e060460a72feafee079d3f
with:
message: 'Detected different CRDs in the `config/crd/bases` directory and `charts/aws-pca-issuer/crds` directory. These CRDs have been synced and the commit has been added to this PR for review.'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Comment on pull request that CRDs were unable to be synced
if: ${{ failure() }}
uses: divyansh-gupta/actions-comment-pull-request@675cdfe1695d33e816e060460a72feafee079d3f
with:
message: |
Detected different CRDs in the `config/crd/bases` directory and `charts/aws-pca-issuer/crds` directory.
Since both CRDs were modified in this commit(s), they were unable to be automatically synced. Please update the pull request with identical CRDs for this workflow to pass.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}