Skip to content

ci

ci #239

Workflow file for this run

name: ci
on:
#push:
# branches: [main]
schedule:
- cron: '0 0 * * 0'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Git Global Conf
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git config --global push.autoSetupRemote true
- id: get-sha
run: |
echo ::set-output name=sha::$(git log -1 --pretty=format:"%H")
- id: get-new-branch
run: |
DATE_BRANCH=$(date +"%m-%d-%y")
echo ::set-output name=branch::$(echo feature/new-ami-release-${DATE_BRANCH})
- name: Git new Branch
run: |
git fetch --all
exists=`git ls-remote --heads origin ${{ steps.get-new-branch.outputs.branch }};`
if [ -n "$exists" ]; then
echo "Branch ${{ steps.get-new-branch.outputs.branch }} Exists..."
git checkout --track origin/${{ steps.get-new-branch.outputs.branch }}
else
echo "Branch " + ${{ steps.get-new-branch.outputs.branch }} + " Does not Exists..."
git checkout -b ${{ steps.get-new-branch.outputs.branch }}
fi
- name: Apply new changes
run: |
wget -O new-amazon-eks-ami-master.zip "https://github.com/awslabs/amazon-eks-ami/archive/refs/heads/master.zip"
unzip new-amazon-eks-ami-master.zip
rm -rf ./new-amazon-eks-ami-master.zip
rm -rf ./amazon-eks-ami-master/.git
rsync -av ./amazon-eks-ami-master/ ./amazon-eks-ami/
rm -rf ./amazon-eks-ami-master/
if [ -n "$(git status --porcelain)" ]; then
echo "new_git_changes=yes" >> $GITHUB_ENV
else
echo "new_git_changes=no" >> $GITHUB_ENV
fi
- name: Commit changes
run: |
if [ ${{ env.new_git_changes }} == 'yes' ]; then
git add .
git commit -am "Auto commit - CI build"
git push
fi
- name: Create a Github PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ ${{ env.new_git_changes }} == 'yes' ]; then
gh pr create --title "New AMI version for EKS - Auto-PR" --body "New version, EKS AMI releases on <https://github.com/awslabs/amazon-eks-ami/releases/>"
else
echo "######## No Changes! ##############################"
fi