-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First implementation of setup buildx action (#1)
- Loading branch information
Showing
13 changed files
with
9,157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: e2e | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: read # This is required for actions/checkout | ||
|
||
jobs: | ||
build_and_push: | ||
runs-on: ubuntu-latest | ||
name: Build and push a sample application to Namespace Cloud | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Namespace Cloud CLI | ||
id: nscloud | ||
uses: namespacelabs/[email protected] | ||
- name: Configure buildx | ||
uses: ./ # Uses an action in the root directory | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: .github/workflows/testdata/Dockerfile | ||
push: ${{ github.ref_name == 'main' }} | ||
tags: "${{ steps.nscloud.outputs.registry-address }}/nscloud-setup-buildx-action/testdata/server:latest" | ||
cache-from: "type=registry,ref=${{ steps.nscloud.outputs.registry-address }}/nscloud-setup-buildx-action/testdata/server:buildcache" | ||
cache-to: "type=registry,ref=${{ steps.nscloud.outputs.registry-address }}/nscloud-setup-buildx-action/testdata/server:buildcache,mode=max" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM alpine:3.17.2 | ||
CMD ["echo", "Hello Namespace!"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Create a Namespace Cloud cluster | ||
|
||
This repository hosts a GitHub action that configures buildx to use a | ||
[Namespace Cloud](https://cloud.namespace.so) build cluster. | ||
|
||
## Example | ||
|
||
```yaml | ||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
# These permissions are needed to interact with GitHub's OIDC Token endpoint. | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install and configure Namespace Cloud CLI | ||
uses: namespacelabs/[email protected] | ||
- name: Configure buildx | ||
uses: namespacelabs/[email protected] | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: user/app:latest | ||
``` | ||
## Requirements | ||
This action uses `nsc`, the Namespace Cloud CLI. | ||
You can add it to your workflow using [namespacelabs/nscloud-setup](https://github.com/namespacelabs/nscloud-setup) | ||
(see [example](#example)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: '"Configure buildx with Namespace Cloud" Action For GitHub Actions' | ||
description: "Configure buildx to use the Namespace Cloud build cluster" | ||
|
||
runs: | ||
using: node16 | ||
main: dist/main/index.js | ||
post: dist/post/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as path from "path"; | ||
import * as fs from "fs"; | ||
|
||
export const SessionId = "NscBuildkitProxySession"; | ||
|
||
export function tmpFile(file: string): string { | ||
const tmpDir = path.join(process.env.RUNNER_TEMP, "ns"); | ||
|
||
if (!fs.existsSync(tmpDir)) { | ||
fs.mkdirSync(tmpDir); | ||
} | ||
|
||
return path.join(tmpDir, file); | ||
} |
Oops, something went wrong.