mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-25 14:12:14 -05:00
parent
b3e0c02dc5
commit
c2d79260cf
4 changed files with 111 additions and 211 deletions
|
@ -7,18 +7,10 @@
|
|||
############
|
||||
# Defaults #
|
||||
############\
|
||||
GITHUB_API='https://api.github.com' # API url
|
||||
VERSION='' # Version of release pulled from api
|
||||
ACTION_FILE='action.yml' # Action file to update
|
||||
PR_ID='' # PUll Request ID when created
|
||||
UPDATED_BODY_STRING='' # Issue body string converted
|
||||
COMMIT_SHA='' # COmmit sha when PR is created
|
||||
|
||||
##############
|
||||
# Built Vars #
|
||||
##############
|
||||
ORG=$(echo "${ORG_REPO}" | cut -d'/' -f1) # Name of the Org
|
||||
REPO=$(echo "${ORG_REPO}" | cut -d'/' -f2) # Name of the repository
|
||||
ACTION_FILE='action.yml' # Action file to update
|
||||
COMMIT_SHA='' # Commit sha when PR is created
|
||||
PR_ID='' # Pull Request NUmber when generated
|
||||
VERSION='' # Version of release pulled from api
|
||||
|
||||
################################################################################
|
||||
############################ FUNCTIONS BELOW ###################################
|
||||
|
@ -31,13 +23,13 @@ Header() {
|
|||
echo "-------------------------------------------------------"
|
||||
}
|
||||
################################################################################
|
||||
#### Function GetReleaseFromIssueTitle #########################################
|
||||
GetReleaseFromIssueTitle() {
|
||||
#### Function GetReleaseVersion #########################################
|
||||
GetReleaseVersion() {
|
||||
echo "-------------------------------------------------------"
|
||||
echo "Getting the latest Release version from GitHub Issue..."
|
||||
echo "Getting the latest Release version from GitHub ..."
|
||||
|
||||
# Get the latest release on the Repository
|
||||
GET_VERSION_CMD=$(echo "${ISSUE_TITLE}" | grep -E -o "v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+" 2>&1)
|
||||
GET_VERSION_CMD=$(echo "${RELEASE_NAME}" | grep -E -o "v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+" 2>&1)
|
||||
|
||||
# Load the error code
|
||||
ERROR_CODE=$?
|
||||
|
@ -160,94 +152,7 @@ CommitAndPush() {
|
|||
fi
|
||||
|
||||
}
|
||||
################################################################################
|
||||
#### Function UpdateBaseIssue ##################################################
|
||||
UpdateBaseIssue() {
|
||||
echo "-------------------------------------------------------"
|
||||
echo "Updating Original Issue:[$ISSUE_NUMBER] with Release information..."
|
||||
|
||||
# Update the issue to point to new created Pull Request
|
||||
UPDATE_ISSUE_CMD=$(curl -s --fail -X POST \
|
||||
--url "${GITHUB_API}/repos/${ORG}/${REPO}/issues/${ISSUE_NUMBER}/comments" \
|
||||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data "{ \"body\": \"This Issue is being resolved on in the Pull Request #${PR_ID}\"}" 2>&1)
|
||||
|
||||
# Load the error code
|
||||
ERROR_CODE=$?
|
||||
|
||||
# Check the shell for errors
|
||||
if [ "${ERROR_CODE}" -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to update base issue!"
|
||||
echo "ERROR:[$UPDATE_ISSUE_CMD]"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully updated base Issue"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
#### Function UpdatePRBody #####################################################
|
||||
UpdatePRBody() {
|
||||
echo "-------------------------------------------------------"
|
||||
echo "Updating PR body with Release information and Issue linkage..."
|
||||
|
||||
# Need to update the body of the PR with the information
|
||||
UPDATE_PR_CMD=$(
|
||||
curl -s --fail -X PATCH \
|
||||
--url "${GITHUB_API}/repos/${ORG}/${REPO}/pulls/${PR_ID}" \
|
||||
-H 'Accept: application/vnd.github.shadow-cat-preview+json,application/vnd.github.sailor-v-preview+json' \
|
||||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data "{\"body\": \"Automation Creation of Super-Linter\n\nThis closes #${ISSUE_NUMBER}\n\n${UPDATED_BODY_STRING}\"}" 2>&1
|
||||
)
|
||||
|
||||
# Load the error code
|
||||
ERROR_CODE=$?
|
||||
|
||||
# Check the shell for errors
|
||||
if [ "${ERROR_CODE}" -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to update PR body!"
|
||||
echo "ERROR:[$UPDATE_PR_CMD]"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully updated PR body"
|
||||
fi
|
||||
|
||||
# Add the label for the release
|
||||
UPDATE_LABEL_CMD=$(
|
||||
curl -s --fail -X POST \
|
||||
--url "${GITHUB_API}/repos/${ORG}/${REPO}/issues/${PR_ID}/labels" \
|
||||
-H 'Accept: application/vnd.github.v3+json' \
|
||||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data '{"labels":["Release"]}' 2>&1
|
||||
)
|
||||
|
||||
# Load the error code
|
||||
ERROR_CODE=$?
|
||||
|
||||
# Check the shell for errors
|
||||
if [ "${ERROR_CODE}" -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to update PR label!"
|
||||
echo "ERROR:[$UPDATE_LABEL_CMD]"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully updated PR label"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
#### Function UpdateReleaseBodyString ##########################################
|
||||
UpdateReleaseBodyString() {
|
||||
# Need to convert the string newlines to literal newlines
|
||||
UPDATED_BODY_STRING=$(echo "${ISSUE_BODY}" | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
|
||||
|
||||
echo "-------------------------------------------------------"
|
||||
echo "The updated body string is:[${UPDATED_BODY_STRING}]"
|
||||
echo "-------------------------------------------------------"
|
||||
}
|
||||
################################################################################
|
||||
#### Function SetActionsVariables ##############################################
|
||||
SetActionsVariables() {
|
||||
|
@ -255,14 +160,11 @@ SetActionsVariables() {
|
|||
echo "-------------------------------------------------------"
|
||||
echo "Setting the variables back to GitHub Actions..."
|
||||
|
||||
echo "Setting PR_ID:[${PR_ID}]"
|
||||
echo "PR_ID=${PR_ID}" >>"${GITHUB_ENV}"
|
||||
|
||||
echo "Setting RELEASE_VERSION:[${VERSION}]"
|
||||
echo "RELEASE_VERSION=${VERSION}" >>"${GITHUB_ENV}"
|
||||
|
||||
echo "Setting PR_REF:[Automation-Release-${VERSION}]"
|
||||
echo "PR_REF=Automation-Release-${VERSION}" >>"${GITHUB_ENV}"
|
||||
echo "Setting PR_ID:[${PR_ID}]"
|
||||
echo "PR_ID=${PR_ID}" >>"${GITHUB_ENV}"
|
||||
|
||||
echo "Setting COMMIT_SHA:[${COMMIT_SHA}]"
|
||||
echo "COMMIT_SHA=${COMMIT_SHA}" >>"${GITHUB_ENV}"
|
||||
|
@ -286,12 +188,7 @@ Header
|
|||
##########################
|
||||
# Get the latest version #
|
||||
##########################
|
||||
GetReleaseFromIssueTitle
|
||||
|
||||
##########################
|
||||
# Get the latest version #
|
||||
##########################
|
||||
UpdateReleaseBodyString
|
||||
GetReleaseVersion
|
||||
|
||||
##########################
|
||||
# Update the action file #
|
||||
|
@ -303,16 +200,6 @@ UpdateActionFile
|
|||
########################
|
||||
CommitAndPush
|
||||
|
||||
####################
|
||||
# Update the Issue #
|
||||
####################
|
||||
UpdateBaseIssue
|
||||
|
||||
####################
|
||||
# Update the Issue #
|
||||
####################
|
||||
UpdatePRBody
|
||||
|
||||
#####################################
|
||||
# Set the variables back to Actions #
|
||||
#####################################
|
||||
|
|
15
.github/ISSUE_TEMPLATE/CREATE_RELEASE.md
vendored
15
.github/ISSUE_TEMPLATE/CREATE_RELEASE.md
vendored
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
name: Create Release
|
||||
about: Create a Release to the Super Linter
|
||||
title: 'Super-Linter Release: vX.Y.Z'
|
||||
labels: release
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Changelog
|
||||
|
||||
<!-- This is the Release body to add all the information -->
|
||||
|
||||
## Bugs
|
||||
|
||||
<!-- This is the Release body to add all the information -->
|
74
.github/workflows/deploy-RELEASE-slim.yml
vendored
74
.github/workflows/deploy-RELEASE-slim.yml
vendored
|
@ -14,9 +14,9 @@
|
|||
# Start the job on all push to master #
|
||||
#######################################
|
||||
on:
|
||||
# Start when a pull request is opened
|
||||
issues:
|
||||
types: ['opened']
|
||||
# Start when a release is published
|
||||
release:
|
||||
types: ['published']
|
||||
|
||||
###############
|
||||
# Set the Job #
|
||||
|
@ -31,8 +31,7 @@ jobs:
|
|||
#####################################################################
|
||||
# Only run if Admin start job and it was the Release Issue template #
|
||||
#####################################################################
|
||||
if: contains(github.event.issue.title, 'Super-Linter Release:') &&
|
||||
github.actor == 'admiralawkbar' || github.actor == 'jwiebalk' ||
|
||||
if: github.actor == 'admiralawkbar' || github.actor == 'jwiebalk' ||
|
||||
github.actor == 'IAmHughes' || github.actor == 'nemchik' ||
|
||||
github.actor == 'Hanse00' || github.actor == 'github-actions' ||
|
||||
github.actor == 'GaboFDC' || github.actor == 'ferrarimarco'
|
||||
|
@ -47,24 +46,6 @@ jobs:
|
|||
- name: Checkout Code
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
#######################################################
|
||||
# Create a GitHub Issue with the info from this build #
|
||||
#######################################################
|
||||
- name: Update GitHub Issue
|
||||
uses: actions/github-script@v4.0.2
|
||||
id: update-issue
|
||||
with:
|
||||
# https://octokit.github.io/rest.js/v18#issues-create
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
github.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: "${{ github.event.issue.number }}",
|
||||
title: "Deploying slim Super-Linter Release to Production",
|
||||
body: 'Currently deploying the Release...'
|
||||
})
|
||||
|
||||
#########################
|
||||
# Update deployment API #
|
||||
#########################
|
||||
|
@ -112,7 +93,7 @@ jobs:
|
|||
###########################
|
||||
- name: Get current Release number
|
||||
run: |
|
||||
echo "RELEASE_VERSION=$(echo "${{ github.event.issue.title }}" \
|
||||
echo "RELEASE_VERSION=$(echo "${{ github.event.release.name }}" \
|
||||
| grep -E -o "v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+")" \
|
||||
>> ${GITHUB_ENV}
|
||||
|
||||
|
@ -173,3 +154,48 @@ jobs:
|
|||
status: ${{ job.status }}
|
||||
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
||||
env_url: https://github.com/github/super-linter/releases/tag/${{ env.RELEASE_VERSION }}
|
||||
|
||||
#######################################################
|
||||
# Create a GitHub Issue with the info from this build #
|
||||
#######################################################
|
||||
- name: Create GitHub Issue for failure
|
||||
if: failure()
|
||||
uses: actions/github-script@v4.0.2
|
||||
id: create-issue
|
||||
with:
|
||||
# https://octokit.github.io/rest.js/v18#issues-create
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
const create = await github.issues.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
title: "Failed to deploy release to production",
|
||||
body: "Automation has failed us! Failed to push release ${{ env.RELEASE_VERSION }}"
|
||||
})
|
||||
console.log('create', create)
|
||||
return create.data.number
|
||||
|
||||
############################
|
||||
# Assign admins on failure #
|
||||
############################
|
||||
- name: Assign Admins on failure
|
||||
uses: actions/github-script@v4.0.2
|
||||
if: failure()
|
||||
with:
|
||||
# https://octokit.github.io/rest.js/v18#issues-create
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
github.issues.addAssignees({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: "${{ steps.create-issue.outputs.result }}",
|
||||
assignees: [
|
||||
'admiralawkbar',
|
||||
'jwiebalk',
|
||||
'IAmHughes',
|
||||
'nemchik',
|
||||
'Hanse00',
|
||||
'GaboFDC',
|
||||
'ferrarimarco'
|
||||
]
|
||||
})
|
||||
|
|
98
.github/workflows/deploy-RELEASE-standard.yml
vendored
98
.github/workflows/deploy-RELEASE-standard.yml
vendored
|
@ -14,9 +14,9 @@
|
|||
# Start the job on all push to master #
|
||||
#######################################
|
||||
on:
|
||||
# Start when a pull request is opened
|
||||
issues:
|
||||
types: ['opened']
|
||||
# Start when a release is published
|
||||
release:
|
||||
types: ['published']
|
||||
|
||||
###############
|
||||
# Set the Job #
|
||||
|
@ -31,8 +31,7 @@ jobs:
|
|||
#####################################################################
|
||||
# Only run if Admin start job and it was the Release Issue template #
|
||||
#####################################################################
|
||||
if: contains(github.event.issue.title, 'Super-Linter Release:') &&
|
||||
github.actor == 'admiralawkbar' || github.actor == 'jwiebalk' ||
|
||||
if: github.actor == 'admiralawkbar' || github.actor == 'jwiebalk' ||
|
||||
github.actor == 'IAmHughes' || github.actor == 'nemchik' ||
|
||||
github.actor == 'Hanse00' || github.actor == 'github-actions' ||
|
||||
github.actor == 'GaboFDC' || github.actor == 'ferrarimarco'
|
||||
|
@ -47,24 +46,6 @@ jobs:
|
|||
- name: Checkout Code
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
#######################################################
|
||||
# Create a GitHub Issue with the info from this build #
|
||||
#######################################################
|
||||
- name: Update GitHub Issue
|
||||
uses: actions/github-script@v4.0.2
|
||||
id: update-issue
|
||||
with:
|
||||
# https://octokit.github.io/rest.js/v18#issues-create
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
github.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: "${{ github.event.issue.number }}",
|
||||
title: "Deploying Super-Linter standard Release to Production",
|
||||
body: 'Currently deploying the Release...'
|
||||
})
|
||||
|
||||
#########################
|
||||
# Update deployment API #
|
||||
#########################
|
||||
|
@ -117,11 +98,7 @@ jobs:
|
|||
# PR_ID PR_REF RELEASE_VERSION COMMIT_SHA
|
||||
env:
|
||||
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
ORG_REPO: ${{ github.repository }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
ISSUE_TITLE: ${{ github.event.issue.title }}
|
||||
ISSUE_BODY: ${{ github.event.issue.body }}
|
||||
RELEASE_NAME: ${{ github.event.release.name }}
|
||||
|
||||
################
|
||||
# Docker cache #
|
||||
|
@ -168,26 +145,6 @@ jobs:
|
|||
rm -rf /tmp/.buildx-cache
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
||||
#############################
|
||||
# Create the GitHub Release #
|
||||
#############################
|
||||
- name: Create Release
|
||||
if: success()
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
# This token is provided by Actions,
|
||||
# you do not need to create your own token
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
commitish: ${{ env.PR_REF }}
|
||||
tag_name: ${{ env.RELEASE_VERSION }}
|
||||
release_name: Release ${{ env.RELEASE_VERSION }}
|
||||
body: |
|
||||
${{ github.event.issue.body }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
#####################################################
|
||||
# Create the Required status check for Stack Linter #
|
||||
#####################################################
|
||||
|
@ -222,3 +179,48 @@ jobs:
|
|||
status: ${{ job.status }}
|
||||
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
||||
env_url: https://github.com/github/super-linter/releases/tag/${{ env.RELEASE_VERSION }}
|
||||
|
||||
#######################################################
|
||||
# Create a GitHub Issue with the info from this build #
|
||||
#######################################################
|
||||
- name: Create GitHub Issue for failure
|
||||
if: failure()
|
||||
uses: actions/github-script@v4.0.2
|
||||
id: create-issue
|
||||
with:
|
||||
# https://octokit.github.io/rest.js/v18#issues-create
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
const create = await github.issues.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
title: "Failed to deploy release to production",
|
||||
body: "Automation has failed us! Failed to push release ${{ env.RELEASE_VERSION }}"
|
||||
})
|
||||
console.log('create', create)
|
||||
return create.data.number
|
||||
|
||||
############################
|
||||
# Assign admins on failure #
|
||||
############################
|
||||
- name: Assign Admins on failure
|
||||
uses: actions/github-script@v4.0.2
|
||||
if: failure()
|
||||
with:
|
||||
# https://octokit.github.io/rest.js/v18#issues-create
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
github.issues.addAssignees({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: "${{ steps.create-issue.outputs.result }}",
|
||||
assignees: [
|
||||
'admiralawkbar',
|
||||
'jwiebalk',
|
||||
'IAmHughes',
|
||||
'nemchik',
|
||||
'Hanse00',
|
||||
'GaboFDC',
|
||||
'ferrarimarco'
|
||||
]
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue