diff --git a/.github/workflows/check-crc.yml b/.github/workflows/check-crc.yml new file mode 100644 index 000000000..47e69d906 --- /dev/null +++ b/.github/workflows/check-crc.yml @@ -0,0 +1,39 @@ +name: check-crc + +on: + schedule: + - cron: "0 8 * * *" + +jobs: + check-crc-repo: + runs-on: ubuntu-latest + env: + TOOL_REPO: crc-org/crc + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Check Out Code + uses: actions/checkout@v2 + - name: Get latest CRC version + run: | + echo "REPO_CRC_VERSION=$(cat src/tools.json | jq -r .crc.crcVersion)" >> $GITHUB_ENV + LATEST_TOOL_RELEASE_RESP=$(gh release --repo ${{ env.TOOL_REPO }} view --json tagName,name,url) + echo "LATEST_TOOL_RELEASE=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .tagName | sed 's|v||')" >> $GITHUB_ENV + echo "LATEST_TOOL_URL=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .url)" >> $GITHUB_ENV + echo "LATEST_OPENSHIFT_RELEASE=$(echo ${LATEST_TOOL_RELEASE_RESP} | jq -r .name | cut -d'-' -f2)" >> $GITHUB_ENV + - name: Find existing PR for CRC version + run: | + echo "PR_EXISTS=$(gh pr --repo ${{ github.repository }} list --state all --search "update crc ${{env.LATEST_TOOL_RELEASE}} in:title" --json url | jq length)" >> $GITHUB_ENV + - name: Update src/tools.json with latest crc version + if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_CRC_VERSION) && (env.PR_EXISTS == 0) }} + run: | + jq --indent 4 '.crc.crcVersion = "${{ env.LATEST_TOOL_RELEASE }}"' src/tools.json | jq --indent 4 '.crc.openshiftVersion = "^${{ env.LATEST_OPENSHIFT_RELEASE }}"' > src/tools.json.new + mv src/tools.json.new src/tools.json + - name: Create pull request + if: ${{ (env.LATEST_TOOL_RELEASE != env.REPO_CRC_VERSION) && (env.PR_EXISTS == 0) }} + run: | + git config --global user.email "openshifttools-bot@users.noreply.github.com" + git config --global user.name "openshifttools-bot" + git checkout -b "crc-${{ env.LATEST_TOOL_RELEASE }}" + git commit -am "Update crc to ${{ env.LATEST_TOOL_RELEASE }}" + git push origin "crc-${{ env.LATEST_TOOL_RELEASE }}" + gh pr create --title "Update crc to ${{ env.LATEST_TOOL_RELEASE }}" --body "See ${{ env.LATEST_TOOL_URL }}" diff --git a/src/tools.json b/src/tools.json index 9bb4c29a0..95ba6312c 100644 --- a/src/tools.json +++ b/src/tools.json @@ -88,5 +88,12 @@ "cmdFileName": "helm-linux-amd64" } } + }, + "crc": { + "description": "crc openshift container", + "vendor": "Red Hat, Inc.", + "name": "crc", + "crcVersion": "2.10.1", + "openshiftVersion": "4.11.7" } } diff --git a/src/webview/cluster/app/cluster.tsx b/src/webview/cluster/app/cluster.tsx index 3ca2989a0..e1ec2d2b3 100644 --- a/src/webview/cluster/app/cluster.tsx +++ b/src/webview/cluster/app/cluster.tsx @@ -53,10 +53,15 @@ const vscodeApi = window.vscodeApi; export default function Header() { const classes = useStyles(); const [showWizard, setShowWizard] = React.useState(''); + const [crcLatest, setCrcLatest] = React.useState(''); + const [crcOpenShift, setCrcOpenShift] = React.useState(''); window.onmessage = (event: any) => { if (['crc', 'sandbox'].includes(event.data.param)) { setShowWizard(event.data.param); + } else if (event.data.action === 'openCrcAddClusterPage') { + setCrcLatest(event.data.crc); + setCrcOpenShift(event.data.openShiftCRC); } } @@ -159,7 +164,7 @@ export default function Header() { Red Hat OpenShift Local brings a minimal OpenShift 4 cluster to your local computer.

You can use this guided workflow to create OpenShift cluster locally. Cluster take approximately 15 minutes to provision.
- + )} diff --git a/src/webview/cluster/app/clusterView.tsx b/src/webview/cluster/app/clusterView.tsx index e594e1d79..9e4ee4a56 100644 --- a/src/webview/cluster/app/clusterView.tsx +++ b/src/webview/cluster/app/clusterView.tsx @@ -29,7 +29,7 @@ import { import { makeStyles, withStyles } from '@mui/styles'; import * as React from 'react'; import * as ClusterViewStyles from './clusterView.style'; - +import { ClusterViewProps } from '../../common/propertyTypes'; const prettyBytes = require('pretty-bytes'); const useStyles = makeStyles(ClusterViewStyles.useStyles); @@ -50,10 +50,8 @@ function getSteps() { } // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -export default function addClusterView(props) { +export default function addClusterView(props: ClusterViewProps) { const classes = useStyles(); - const crcLatest = '2.10.1'; - const crcOpenShift = '4.11.7'; const [fileName, setBinaryPath] = React.useState(''); const [pullSecretPath, setSecret] = React.useState(''); const [cpuSize, setCpuSize] = React.useState(crcDefaults.DefaultCPUs); @@ -292,7 +290,7 @@ export default function addClusterView(props) { if (platform === 'darwin') crcBundle = 'crc-macos-amd64.pkg'; if (platform === 'win32') crcBundle = 'crc-windows-installer.zip'; if (platform === 'linux') crcBundle = 'crc-linux-amd64.tar.xz'; - return `${crcDefaults.DefaultCrcUrlBase}/${crcLatest}/${crcBundle}`; + return `${crcDefaults.DefaultCrcUrlBase}/${props.crc}/${crcBundle}`; } const RunningStatus = ()=> ( @@ -457,7 +455,7 @@ export default function addClusterView(props) { } /> This will download OpenShift Local {crcLatest}}/> + secondary={This will download OpenShift Local {props.crc}}/>