mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-21 21:50:59 -05:00
parent
aea45684dd
commit
8eb4d621d6
4 changed files with 31 additions and 247 deletions
|
@ -1,211 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
############# Update the actions.yml with version @admiralawkbar ###############
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
############
|
|
||||||
# Defaults #
|
|
||||||
############\
|
|
||||||
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 ###################################
|
|
||||||
################################################################################
|
|
||||||
################################################################################
|
|
||||||
#### Function Header ###########################################################
|
|
||||||
Header() {
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo "----------- GitHub Update Release Version -------------"
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function GetReleaseVersion #########################################
|
|
||||||
GetReleaseVersion() {
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo "Getting the latest Release version from GitHub ..."
|
|
||||||
|
|
||||||
# Get the latest release on the Repository
|
|
||||||
GET_VERSION_CMD="$(echo "${RELEASE_NAME}" | grep -E -o "v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+" 2>&1)"
|
|
||||||
|
|
||||||
# Load the error code
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
# Check the shell for errors
|
|
||||||
if [ "${ERROR_CODE}" -ne 0 ] || [ ${#GET_VERSION_CMD} -lt 1 ]; then
|
|
||||||
# Error
|
|
||||||
echo "ERROR! Failed to get the version!"
|
|
||||||
echo "ERROR:[${GET_VERSION_CMD}]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# Success
|
|
||||||
echo "Latest Version:[${GET_VERSION_CMD}]"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set the version
|
|
||||||
VERSION=${GET_VERSION_CMD}
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function UpdateActionFile #################################################
|
|
||||||
UpdateActionFile() {
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo "Updating the File:[$ACTION_FILE] with Version:[$VERSION]..."
|
|
||||||
|
|
||||||
# Validate we can see the file
|
|
||||||
if [ ! -f "${ACTION_FILE}" ]; then
|
|
||||||
# ERROR
|
|
||||||
echo "ERROR! Failed to find the file:[${ACTION_FILE}]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update the file
|
|
||||||
UPDATE_CMD=$(sed -i "s|image:.*|image: 'docker://ghcr.io/github/super-linter:${VERSION}'|" "${ACTION_FILE}" 2>&1)
|
|
||||||
|
|
||||||
# Load the error code
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
# Check the shell for errors
|
|
||||||
if [ "${ERROR_CODE}" -ne 0 ]; then
|
|
||||||
# Failed to update file
|
|
||||||
echo "ERROR! Failed to update ${ACTION_FILE}!"
|
|
||||||
echo "ERROR:[${UPDATE_CMD}]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Successfully updated file to:"
|
|
||||||
cat "${ACTION_FILE}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function CommitAndPush ####################################################
|
|
||||||
CommitAndPush() {
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo "Creating commit, and pushing to PR..."
|
|
||||||
|
|
||||||
# Commit the code to GitHub
|
|
||||||
COMMIT_CMD=$(
|
|
||||||
git checkout -b "Automation-Release-${VERSION}"
|
|
||||||
git add "${ACTION_FILE}"
|
|
||||||
git config --global user.name "SuperLinter Automation"
|
|
||||||
git config --global user.email "super_linter_automation@github.com"
|
|
||||||
git commit -m "Updating action.yml with new release version" 2>&1
|
|
||||||
)
|
|
||||||
|
|
||||||
# Load the error code
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
# Check the shell for errors
|
|
||||||
if [ "${ERROR_CODE}" -ne 0 ]; then
|
|
||||||
# ERROR
|
|
||||||
echo "ERROR! Failed to make commit!"
|
|
||||||
echo "ERROR:[$COMMIT_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Successfully staged commmit"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
# Push the code to the branch and create PR
|
|
||||||
PUSH_CMD=$(
|
|
||||||
git push --set-upstream origin "Automation-Release-${VERSION}"
|
|
||||||
gh pr create --title "Release-update-to-${VERSION}" --body "Automation Upgrade version ${VERSION} to action.yml" 2>&1
|
|
||||||
)
|
|
||||||
|
|
||||||
# Load the error code
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
# Check the shell for errors
|
|
||||||
if [ "${ERROR_CODE}" -ne 0 ]; then
|
|
||||||
# ERROR
|
|
||||||
echo "ERROR! Failed to create PR!"
|
|
||||||
echo "ERROR:[$PUSH_CMD]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Successfully Created PR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get the pr number
|
|
||||||
for LINE in $PUSH_CMD; do
|
|
||||||
# echo "Line:[${LINE}]"
|
|
||||||
if [[ "${LINE}" == *"github.com"* ]]; then
|
|
||||||
# Getting the PR id
|
|
||||||
PR_ID=$(echo "${LINE}" | rev | cut -d'/' -f1 | rev)
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# get the current commit sha
|
|
||||||
COMMIT_SHA=$(git rev-parse HEAD 2>&1)
|
|
||||||
|
|
||||||
# Load the error code
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
# Check the shell for errors
|
|
||||||
if [ "${ERROR_CODE}" -ne 0 ]; then
|
|
||||||
# ERROR
|
|
||||||
echo "ERROR! Failed to get comit sha!"
|
|
||||||
echo "ERROR:[$COMMIT_SHA]"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Successfully grabbed commit sha"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
#### Function SetActionsVariables ##############################################
|
|
||||||
SetActionsVariables() {
|
|
||||||
# Set the variables back to Actions
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo "Setting the variables back to GitHub Actions..."
|
|
||||||
|
|
||||||
echo "Setting RELEASE_VERSION:[${VERSION}]"
|
|
||||||
echo "RELEASE_VERSION=${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}"
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
#### Function Footer ###########################################################
|
|
||||||
Footer() {
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
echo "The step has completed"
|
|
||||||
echo "-------------------------------------------------------"
|
|
||||||
}
|
|
||||||
################################################################################
|
|
||||||
################################## MAIN ########################################
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Header #
|
|
||||||
##########
|
|
||||||
Header
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# Get the latest version #
|
|
||||||
##########################
|
|
||||||
GetReleaseVersion
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# Update the action file #
|
|
||||||
##########################
|
|
||||||
UpdateActionFile
|
|
||||||
|
|
||||||
########################
|
|
||||||
# Commit and push file #
|
|
||||||
########################
|
|
||||||
CommitAndPush
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
# Set the variables back to Actions #
|
|
||||||
#####################################
|
|
||||||
SetActionsVariables
|
|
||||||
|
|
||||||
##########
|
|
||||||
# Footer #
|
|
||||||
##########
|
|
||||||
Footer
|
|
35
.github/workflows/deploy-RELEASE-standard.yml
vendored
35
.github/workflows/deploy-RELEASE-standard.yml
vendored
|
@ -88,19 +88,6 @@ jobs:
|
||||||
password: ${{ secrets.GCR_TOKEN }}
|
password: ${{ secrets.GCR_TOKEN }}
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
|
|
||||||
#######################################
|
|
||||||
# Update actions.yml with new version #
|
|
||||||
#######################################
|
|
||||||
- name: Update actions.yml with release version and create PR
|
|
||||||
if: success()
|
|
||||||
run: ./.automation/update-actions-version.sh
|
|
||||||
# Note: script creates variables:
|
|
||||||
# PR_ID PR_REF RELEASE_VERSION COMMIT_SHA
|
|
||||||
env:
|
|
||||||
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
|
|
||||||
RELEASE_NAME: ${{ github.event.release.name }}
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
################
|
################
|
||||||
# Docker cache #
|
# Docker cache #
|
||||||
################
|
################
|
||||||
|
@ -146,28 +133,6 @@ jobs:
|
||||||
rm -rf /tmp/.buildx-cache
|
rm -rf /tmp/.buildx-cache
|
||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
#####################################################
|
|
||||||
# Create the Required status check for Stack Linter #
|
|
||||||
#####################################################
|
|
||||||
- name: Create Stack Linter Status
|
|
||||||
if: success()
|
|
||||||
run: |
|
|
||||||
curl -X POST --url "https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }}" \
|
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
|
||||||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
|
||||||
--data '{ "state": "success", "context": "Stack linter" }'
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Close the opened Pull Request #
|
|
||||||
#################################
|
|
||||||
- name: Close PR
|
|
||||||
if: success()
|
|
||||||
run: |
|
|
||||||
curl -X PUT --url "https://api.github.com/repos/${{ github.repository }}/pulls/${{ env.PR_ID }}/merge" \
|
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
|
||||||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
|
||||||
--data '{ "merge_method": "squash" }'
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Update Deployment API #
|
# Update Deployment API #
|
||||||
#########################
|
#########################
|
||||||
|
|
|
@ -4,7 +4,7 @@ author: 'GitHub'
|
||||||
description: 'It is a simple combination of various linters, written in bash, to help validate your source code.'
|
description: 'It is a simple combination of various linters, written in bash, to help validate your source code.'
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'docker://ghcr.io/github/super-linter:v4.7.0'
|
image: 'docker://ghcr.io/github/super-linter:v4.7.1'
|
||||||
branding:
|
branding:
|
||||||
icon: 'check-square'
|
icon: 'check-square'
|
||||||
color: 'white'
|
color: 'white'
|
||||||
|
|
30
docs/release-process.md
Normal file
30
docs/release-process.md
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# Creating GitHub Super-Linter Release
|
||||||
|
|
||||||
|
The Process to create a `Release` of the **GitHub/Super-Linter** is as follows:
|
||||||
|
|
||||||
|
- Every push to `master/main` triggers a build and deploy of the **GitHub/Super-linter**
|
||||||
|
- This creates the following images:
|
||||||
|
- `github/super-linter:latest`
|
||||||
|
- `github/super-linter:slim-latest`
|
||||||
|
- This also causes the `Release drafter` action to update a new draft Release
|
||||||
|
|
||||||
|
When an *Admin* wants to create a Release, the process is as follows:
|
||||||
|
- The *Admin* pushes an update to `master/main` and updates the `action.yml` to point to the next **Release** version
|
||||||
|
- Example: `image: 'docker://ghcr.io/github/super-linter:v4.6.2'` becomes: `image: 'docker://ghcr.io/github/super-linter:v4.6.3'`
|
||||||
|
- Then the *admin* can go to the Release page and update the current `draft Release`
|
||||||
|
- The *Admin* will set the correct version strings, and update any additional information in the current `draft Release`
|
||||||
|
- Once the *Admin* is ready, they will select **Publish Release**
|
||||||
|
- This triggers the **GitHub Actions** to take the current codebase, and build the containers, and deploy to their locations
|
||||||
|
- This creates the following images:
|
||||||
|
- `github/super-linter:latest`
|
||||||
|
- `github/super-linter:v4`
|
||||||
|
- `github/super-linter:v4.6.3`
|
||||||
|
- `github/super-linter:slim-latest`
|
||||||
|
- `github/super-linter:slim-v4`
|
||||||
|
- `github/super-linter:slim-v4.6.3`
|
||||||
|
- At this point, the Release is complete and images are available for general consumption
|
||||||
|
|
||||||
|
## Pitfalls and Issues
|
||||||
|
|
||||||
|
If the *Admin* Does not update the `action.yml` to the new version before the Release is published, then the Release will point back to the old version, and any Images will also be sent back to the previous version.
|
||||||
|
This is very much a chicken and the egg issue, but seems to be easily resolved by following the correct path.
|
Loading…
Reference in a new issue