Skip to content

Produce Docker Image, GH Release & Create PR for Override File #631

Produce Docker Image, GH Release & Create PR for Override File

Produce Docker Image, GH Release & Create PR for Override File #631

name: Produce Docker Image, GH Release & Create PR for Override File
on:
workflow_dispatch:
schedule:
- cron: '0 13 * * 1-5' # M-F at 6 AM PDT
jobs:
# Compare kubernetes/ingress-nginx version with sigsci-nginx-ingress-controller version
# If new version build and push container to docker hub
# Create and tag new release
# Update sigsci-value.yaml file & create PR
compare_versions:
runs-on: ubuntu-latest
env:
GH_REPO: https://api.github.com/repos/signalsciences/sigsci-nginx-ingress-controller
outputs:
value: ${{ steps.tag.outputs.NO_CHANGE }}
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_API_TOKEN }}
- name: compare versions
id: tag
env:
REPO: signalsciences/sigsci-nginx-ingress-controller
run: |
INGRESS_LATEST=$(./scripts/latest-version.sh upstream)
SIGSCI_LATEST=$(./scripts/latest-version.sh sigsci)
if [ "$INGRESS_LATEST" == "$SIGSCI_LATEST" ]; then
echo "ingress-nginx version: $INGRESS_LATEST matches sigsci version: $SIGSCI_LATEST"
echo "::set-output name=NO_CHANGE::true"
else
TAG=$INGRESS_LATEST
docker buildx create --name build_multiarch --use
docker buildx build --platform linux/amd64,linux/arm64 --build-arg NGINX_INGRESS_VERSION=v${TAG} --tag ${REPO}:${TAG} --tag ${REPO}:latest --push .
echo NEW_TAG=$TAG >> $GITHUB_ENV
echo "::set-output name=NO_CHANGE::false"
fi
- name: Create Release
if: ${{ steps.tag.outputs.NO_CHANGE == 'false' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_TAG }}
release_name: Match release ${{ env.NEW_TAG }}
body: |
Match release kubernetes/ingress-nginx v${{ env.NEW_TAG }}
draft: false
prerelease: false
- name: Update sigsci-values.yaml & create PR
if: ${{ steps.tag.outputs.NO_CHANGE == 'false' }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git checkout -b match-version-release
sed -i "s/tag:.*/tag: \"${{ env.NEW_TAG }}\"/g" sigsci-values.yaml
git commit -am "Automated PR - Match upstream version" && git push -u origin match-version-release
curl -X POST -u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} \
${{ env.GH_REPO }}/pulls --data '{"head":"match-version-release","base":"main","body":"Automated PR","title":"Match Version ${{ env.NEW_TAG}}"}'
- name: Pull latest PR Num
if: ${{ steps.tag.outputs.NO_CHANGE == 'false' }}
run: |
pr_number=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \
-u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} \
${{ env.GH_REPO }}/pulls | jq -r '.[].number')
echo PR_NUM=$pr_number >> $GITHUB_ENV
- name: Add reviewers to latest PR
if: ${{ steps.tag.outputs.NO_CHANGE == 'false' }}
run: |
curl -s \
-H "Accept: application/vnd.github.v3+json" \
-u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} \
${{ env.GH_REPO }}/pulls/${{ env.PR_NUM }}/requested_reviewers \
--data '{"reviewers":["bbucher-sigsci","paul-fastly","amacnair","vcarvajal-sigsci","nathan-sigsci","sada-sigsci"]}'