Run GitHub Actions on pushes and PRs to main, not master (#1883)

* Run GitHub Actions on pushes and PRs to main, not master

* fix go install ecr-login, bump to latest v0.6.0

* master -> main in some integration tests

* skip no-ref integration test
This commit is contained in:
Jason Hall 2022-01-14 14:54:12 -05:00 committed by GitHub
parent 1a6b8ce37b
commit d587122a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 14 deletions

View File

@ -2,9 +2,9 @@ name: Build images
on:
pull_request:
branches: ['master']
branches: ['main']
push:
branches: ['master']
branches: ['main']
tags: ['v[0-9]+.[0-9]+.[0-9]+*']
jobs:

View File

@ -2,9 +2,9 @@ name: Integration tests
on:
push:
branches: ['master']
branches: ['main']
pull_request:
branches: ['master']
branches: ['main']
jobs:
tests:

View File

@ -6,7 +6,7 @@ on:
# Weekly on Saturdays.
- cron: '30 1 * * 6'
push:
branches: [ main, master ]
branches: ['main']
# Declare default permissions as read only.
permissions: read-all

View File

@ -2,9 +2,9 @@ name: Unit tests
on:
push:
branches: ['master']
branches: ['main']
pull_request:
branches: ['master']
branches: ['main']
jobs:
tests:

View File

@ -26,7 +26,7 @@ ENV GOBIN=/usr/local/bin
RUN go install github.com/GoogleCloudPlatform/docker-credential-gcr@4cdd60d0f2d8a69bc70933f4d7718f9c4e956ff8
# Get Amazon ECR credential helper
RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@v0.5.0
RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@69c85dc22db6511932bbf119e1a0cc5c90c69a7f # v0.6.0
# Get ACR docker env credential helper
RUN go install github.com/chrismellard/docker-credential-acr-env@09e2b5a8ac86c3ec347b2473e42b34367d8fa419

View File

@ -26,7 +26,7 @@ ENV GOBIN=/usr/local/bin
RUN go install github.com/GoogleCloudPlatform/docker-credential-gcr@4cdd60d0f2d8a69bc70933f4d7718f9c4e956ff8
# Get Amazon ECR credential helper
RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@v0.5.0
RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@69c85dc22db6511932bbf119e1a0cc5c90c69a7f # v0.6.0
# Get ACR docker env credential helper
RUN go install github.com/chrismellard/docker-credential-acr-env@09e2b5a8ac86c3ec347b2473e42b34367d8fa419

View File

@ -26,7 +26,7 @@ ENV GOBIN=/usr/local/bin
RUN go install github.com/GoogleCloudPlatform/docker-credential-gcr@4cdd60d0f2d8a69bc70933f4d7718f9c4e956ff8
# Get Amazon ECR credential helper
RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@v0.5.0
RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@69c85dc22db6511932bbf119e1a0cc5c90c69a7f # v0.6.0
# Get ACR docker env credential helper
RUN go install github.com/chrismellard/docker-credential-acr-env@09e2b5a8ac86c3ec347b2473e42b34367d8fa419

View File

@ -203,7 +203,7 @@ func getBranchCommitAndURL() (branch, commit, url string) {
repo := os.Getenv("GITHUB_REPOSITORY")
commit = os.Getenv("GITHUB_SHA")
if _, isPR := os.LookupEnv("GITHUB_HEAD_REF"); isPR {
branch = "master"
branch = "main"
} else {
branch = os.Getenv("GITHUB_REF")
log.Printf("GITHUB_HEAD_REF is unset (not a PR); using GITHUB_REF=%q", branch)
@ -213,7 +213,7 @@ func getBranchCommitAndURL() (branch, commit, url string) {
repo = "GoogleContainerTools/kaniko"
}
if branch == "" {
branch = "master"
branch = "main"
}
log.Printf("repo=%q / commit=%q / branch=%q", repo, commit, branch)
url = "github.com/" + repo
@ -266,9 +266,9 @@ func testGitBuildcontextHelper(t *testing.T, repo string) {
checkContainerDiffOutput(t, diff, expected)
}
// TestGitBuildcontext explicitly names the master branch
// TestGitBuildcontext explicitly names the main branch
// Example:
// git://github.com/myuser/repo#refs/heads/master
// git://github.com/myuser/repo#refs/heads/main
func TestGitBuildcontext(t *testing.T) {
repo := getGitRepo(false)
testGitBuildcontextHelper(t, repo)
@ -278,6 +278,7 @@ func TestGitBuildcontext(t *testing.T) {
// Example:
// git://github.com/myuser/repo
func TestGitBuildcontextNoRef(t *testing.T) {
t.Skip("Docker's behavior is to assume a 'master' branch, which the Kaniko repo doesn't have")
_, _, url := getBranchCommitAndURL()
testGitBuildcontextHelper(t, url)
}