Update Ansible Templates #107
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Ansible Templates | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
update-template-and-create-pr: | |
if: github.event_name != 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
cache-dependency-path: '**/requirements.txt' | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Configure Environment | |
run: | | |
echo "AUTO_BRANCH=auto-update-templates" >> $GITHUB_ENV | |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV | |
echo "DATE_FMT=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
- name: Configure Git | |
run: | | |
git config user.email "action@github.com" | |
git config user.name "GitHub Action" | |
- name: Fetch and Update Branches | |
run: | | |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* | |
git checkout master | |
git pull origin master | |
git checkout "${{ env.AUTO_BRANCH }}" || git checkout -b "${{ env.AUTO_BRANCH }}" origin/master | |
git rebase master -X theirs | |
- name: Update Project | |
run: python ./scripts/update.py --update-readme --update-directories | |
- name: Commit and Push Changes | |
run: bash ./.github/deployment/commit_and_push.sh | |
- name: Check for Existing Pull Request | |
if: env.CREATE_PR == 'true' | |
id: check-pr | |
run: bash ./.github/deployment/check_for_existing_pr.sh | |
env: | |
AUTO_BRANCH: ${{ env.AUTO_BRANCH }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Ensure Labels Exist | |
if: env.CREATE_PR == 'true' | |
run: bash ./.github/deployment/ensure_github_labels.sh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Pull Request | |
if: env.CREATE_PR == 'true' | |
run: bash ./.github/deployment/create_template_update_pr.sh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |