Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/bump gha versions #5

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/get_latest_skaffold_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Update Version

on:
schedule:
- cron: '0 * * * *' # Runs every hour (adjust as needed)
workflow_dispatch: # Allows manual trigger of the workflow

jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v3

- name: Checkout external repository with depth 1
uses: actions/checkout@v3
with:
repository: GoogleContainerTools/skaffold # External repository
path: external-repo
ref: main # Replace with the branch name if different
fetch-depth: 1 # Only fetch the latest commit

- name: Parse version from markdown file
id: parse_version
run: |
version=$(grep -Eo "--version='skaffold/(v[0-9a-zA-Z]+)'" external-repo/docs-v2/content/en/docs/references/cli/_index.md | sed -E "s/--version='skaffold\/(v[0-9a-zA-Z]+)'/\1/")
echo "VERSION=$version" >> $GITHUB_ENV

- name: Update repository environment variable
run: |
echo "VERSION=$VERSION"
gh api -X PUT "/repos/${{ github.repository }}/actions/variables/VERSION" -f name=VERSION -f value="$VERSION"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion internal/skaffold/skaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -70,9 +71,14 @@ func getLatestSkaffoldYamlVersion() (string, error) {
}
defer resp.Body.Close()

responseContentBytes, err := io.ReadAll(resp.Body)
if err != nil {
log.Printf("Error while reading the response body")
return "", err
}
// Check if the request was successful
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("error: unable to fetch the file. Status code: %d", resp.StatusCode)
return "", fmt.Errorf("error: unable to fetch the file. Status code: %d. Body: %s", resp.StatusCode, string(responseContentBytes))
}

// Decode the JSON response
Expand Down
Loading