mirror of
https://github.com/werf/actions.git
synced 2026-02-06 11:26:24 +03:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ad28e741a | ||
|
|
b3b83d531c | ||
|
|
f3a12bd69b | ||
|
|
af48145692 | ||
|
|
4cd91e1efe | ||
|
|
6ada024d50 | ||
|
|
598155cd9d | ||
|
|
41f4b68701 |
4
.github/workflows/test.yaml
vendored
4
.github/workflows/test.yaml
vendored
@@ -38,6 +38,6 @@ jobs:
|
||||
- name: Install
|
||||
uses: ./install
|
||||
with:
|
||||
version: v1.2.35
|
||||
version: v2.31.1
|
||||
|
||||
- run: werf version
|
||||
- run: werf version
|
||||
|
||||
90
README.md
90
README.md
@@ -5,7 +5,7 @@ ___
|
||||
|
||||
This action allows you to organize CI/CD with GitHub Actions and [werf](https://github.com/werf/werf).
|
||||
|
||||
**Ready-to-use GitHub Actions Workflows** for different CI/CD workflows are available [here](https://werf.io/documentation/v1.2/advanced/ci_cd/github_actions.html#complete-set-of-configurations-for-ready-made-workflows).
|
||||
**Ready-to-use GitHub Actions Workflows** for different CI/CD workflows are available [here](https://werf.io/getting_started/?usage=ci&ci=githubActions&runnerType=hostRunner&os=linux&buildBackend=buildah&projectType=simplified&sharedCICD=no&repoType=application).
|
||||
|
||||
## How to use
|
||||
|
||||
@@ -21,7 +21,7 @@ converge:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install werf
|
||||
uses: werf/actions/install@v1.2
|
||||
uses: werf/actions/install@v2
|
||||
|
||||
- name: Run script
|
||||
run: |
|
||||
@@ -30,19 +30,12 @@ converge:
|
||||
env:
|
||||
WERF_KUBECONFIG_BASE64: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
|
||||
WERF_ENV: production
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
## Versioning
|
||||
|
||||
When using action, select the version corresponding to the required `MAJOR.MINOR` version of werf:
|
||||
|
||||
```yaml
|
||||
# Setup actual werf version within 1.1 alpha channel.
|
||||
- uses: werf/actions/install@v1.1
|
||||
|
||||
# Setup actual werf version within 1.2 alpha channel.
|
||||
- uses: werf/actions/install@v1.2
|
||||
```
|
||||
When using action, select the version corresponding to the required `MAJOR` version of werf.
|
||||
|
||||
By default, the action installs actual werf version within alpha channel (more details about channels, werf release cycle and compatibility promise [here](https://werf.io/installation.html#all-changes-in-werf-go-through-all-stability-channels)).
|
||||
Using the `channel` input the user can switch the release channel.
|
||||
@@ -50,7 +43,7 @@ Using the `channel` input the user can switch the release channel.
|
||||
> This is recommended approach to be up-to-date and to use actual werf version without changing configurations.
|
||||
|
||||
```yaml
|
||||
- uses: werf/actions/install@v1.2
|
||||
- uses: werf/actions/install@v2
|
||||
with:
|
||||
channel: alpha
|
||||
```
|
||||
@@ -58,9 +51,9 @@ Using the `channel` input the user can switch the release channel.
|
||||
Withal, it is not necessary to work within release channels, and the user might specify certain werf version with `version` input.
|
||||
|
||||
```yaml
|
||||
- uses: werf/actions/install@v1.2
|
||||
- uses: werf/actions/install@v2
|
||||
with:
|
||||
version: v1.2.9
|
||||
version: v2.1.0
|
||||
```
|
||||
|
||||
## FAQ
|
||||
@@ -78,7 +71,74 @@ Make sure to use `fetch-depth: 0` setting in the checkout action, like follows:
|
||||
|
||||
By default, fetch-depth set to `1` which disables git history when checking out code. werf cache selection algorithm uses git history to determine whether some image bound to some commit could be used as a cache when building current commit (current commit should be descendant to the cache commit).
|
||||
|
||||
Setting `fetch-depth` to `0` enables full fetch of git history and it is a **recommended** approach. It is also possible to limit fetch history with some decent number of commits, which would enable images caching limited to that number of commits, but this would have a negative impact on cache reproducibility.
|
||||
Setting `fetch-depth` to `0` enables full fetch of git history, and it is a **recommended** approach. It is also possible to limit fetch history with some decent number of commits, which would enable images caching limited to that number of commits, but this would have a negative impact on cache reproducibility.
|
||||
|
||||
### Working with container registry
|
||||
|
||||
If there is a need to perform authorization using custom credentials or in an external container registry, then you have to use a ready-made action tailored to your container registry (or just run `werf cr login`).
|
||||
|
||||
```yaml
|
||||
converge:
|
||||
name: Converge
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install werf
|
||||
uses: werf/actions/install@v2
|
||||
|
||||
- name: cr login
|
||||
run: werf cr login -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_TOKEN }} registry.example.com
|
||||
|
||||
- name: converge
|
||||
run: werf converge
|
||||
env:
|
||||
WERF_KUBECONFIG_BASE64: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
|
||||
WERF_ENV: production
|
||||
WERF_REPO: registry.example.com/repo
|
||||
```
|
||||
|
||||
> Environment variables **`WERF_REPO`** and **`GITHUB_TOKEN`** for converge should only be used if building images is required otherwise they can be omitted
|
||||
|
||||
In the simplest case, if an [integrated GitHub Packages-like container registry](https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages) is used, then the authorization is performed automatically when the `werf ci-env` command is invoked. This command is run with several required arguments such as GitHub environment variables, the [`GITHUB_TOKEN` secret](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret) (you have to explicitly declare it).
|
||||
|
||||
### Building multi-platform images
|
||||
|
||||
To build multi-platform images or customize the build environment, you can use [docker/setup-buildx-action@v3](https://github.com/docker/setup-buildx-action).
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Install werf
|
||||
uses: werf/actions/install@v2
|
||||
|
||||
- name: cr login
|
||||
run: werf cr login -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_TOKEN }} registry.example.com
|
||||
|
||||
- name: converge
|
||||
run: |
|
||||
. $(werf ci-env github --as-file)
|
||||
werf converge
|
||||
env:
|
||||
WERF_KUBECONFIG_BASE64: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
|
||||
WERF_ENV: production
|
||||
```
|
||||
|
||||
> No additional configuration is required, and QEMU is automatically used for cross-platform builds.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ branding:
|
||||
inputs:
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
|
||||
@@ -10,7 +10,7 @@ The action combines all the necessary steps in itself and logic may be divided i
|
||||
```yaml
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
@@ -38,7 +38,7 @@ build:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Build
|
||||
uses: werf/actions/build@v1.2
|
||||
uses: werf/actions/build@v2
|
||||
with:
|
||||
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
|
||||
```
|
||||
|
||||
@@ -7,7 +7,7 @@ branding:
|
||||
inputs:
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
|
||||
695
build/index.js
695
build/index.js
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ The action combines all the necessary steps in itself and logic may be divided i
|
||||
```yaml
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
@@ -39,7 +39,7 @@ cleanup:
|
||||
run: git fetch --prune --unshallow
|
||||
|
||||
- name: Cleanup
|
||||
uses: werf/actions/cleanup@v1.2
|
||||
uses: werf/actions/cleanup@v2
|
||||
with:
|
||||
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
|
||||
env:
|
||||
|
||||
@@ -7,7 +7,7 @@ branding:
|
||||
inputs:
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
|
||||
695
cleanup/index.js
695
cleanup/index.js
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ The action combines all the necessary steps in itself and logic may be divided i
|
||||
```yaml
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
@@ -41,7 +41,7 @@ converge:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Converge
|
||||
uses: werf/actions/converge@v1.2
|
||||
uses: werf/actions/converge@v2
|
||||
with:
|
||||
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
|
||||
env: production
|
||||
|
||||
@@ -7,7 +7,7 @@ branding:
|
||||
inputs:
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ The action combines all the necessary steps in itself and logic may be divided i
|
||||
```yaml
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
@@ -39,7 +39,7 @@ dismiss:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Dismiss
|
||||
uses: werf/actions/dismiss@v1.2
|
||||
uses: werf/actions/dismiss@v2
|
||||
with:
|
||||
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
|
||||
env: production
|
||||
|
||||
@@ -7,7 +7,7 @@ branding:
|
||||
inputs:
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
|
||||
695
dismiss/index.js
695
dismiss/index.js
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@ Using the `channel` input the user can switch the release channel.
|
||||
> This is recommended approach to be up-to-date and to use actual werf version without changing configurations
|
||||
|
||||
```yaml
|
||||
- uses: werf/actions/install@v1.2
|
||||
- uses: werf/actions/install@v2
|
||||
with:
|
||||
channel: alpha
|
||||
```
|
||||
@@ -17,9 +17,9 @@ Using the `channel` input the user can switch the release channel.
|
||||
Withal, it is not necessary to work within release channels, and the user might specify certain werf version with `version` input.
|
||||
|
||||
```yaml
|
||||
- uses: werf/actions/install@v1.2
|
||||
- uses: werf/actions/install@v2
|
||||
with:
|
||||
version: v1.2.9
|
||||
version: v2.1.0
|
||||
```
|
||||
|
||||
## Inputs
|
||||
@@ -27,7 +27,7 @@ Withal, it is not necessary to work within release channels, and the user might
|
||||
```yaml
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
@@ -46,7 +46,7 @@ werf:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install werf CLI
|
||||
uses: werf/actions/install@v1.2
|
||||
uses: werf/actions/install@v2
|
||||
|
||||
# For deploy and distributed locks.
|
||||
- name: Create kube config
|
||||
@@ -63,6 +63,6 @@ werf:
|
||||
werf render
|
||||
werf converge
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
WERF_ENV: production
|
||||
```
|
||||
|
||||
@@ -7,7 +7,7 @@ branding:
|
||||
inputs:
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
|
||||
695
install/index.js
695
install/index.js
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@ The action combines all the necessary steps in itself and logic may be divided i
|
||||
inputs:
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
@@ -45,7 +45,7 @@ run:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Run
|
||||
uses: werf/actions/run@v1.2
|
||||
uses: werf/actions/run@v2
|
||||
with:
|
||||
image: backend
|
||||
args: rails server
|
||||
|
||||
@@ -7,7 +7,7 @@ branding:
|
||||
inputs:
|
||||
channel:
|
||||
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
|
||||
default: 'alpha'
|
||||
default: 'stable'
|
||||
required: false
|
||||
version:
|
||||
description: 'The certain version'
|
||||
|
||||
695
run/index.js
695
run/index.js
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,6 @@ import {String} from 'typescript-string-operations'
|
||||
import {Manager} from './manager'
|
||||
import * as werf from './werf'
|
||||
|
||||
const minimalWerfVersion = 'v1.1.17'
|
||||
|
||||
export async function PrepareEnvironAndRunWerfCommand(
|
||||
args: string[]
|
||||
): Promise<void> {
|
||||
@@ -67,27 +65,15 @@ export function ProcessGitHubContext(): void {
|
||||
|
||||
export function ValidateWerfVersion(version: string): void {
|
||||
const ver = semver.coerce(version)
|
||||
if (ver) {
|
||||
if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) {
|
||||
throw new Error(
|
||||
String.Format(
|
||||
'The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})',
|
||||
version.trim(),
|
||||
werf.MAJOR_MINOR_GROUP
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (semver.gte(ver, minimalWerfVersion)) {
|
||||
return
|
||||
}
|
||||
if (ver && ver.major === werf.MAJOR) {
|
||||
return
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
String.Format(
|
||||
'werf version {0} is not supported (expected version must be equal or greater than {1})',
|
||||
'werf version {0} is not supported: the version must be semver and within the MAJOR ({1})',
|
||||
version.trim(),
|
||||
minimalWerfVersion
|
||||
werf.GROUP
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ export class Manager {
|
||||
return this._constructReleaseUrl(version)
|
||||
}
|
||||
|
||||
const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}`
|
||||
const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}`
|
||||
try {
|
||||
const resp = await request
|
||||
.get(url)
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export const MAJOR_MINOR_GROUP = '1.2'
|
||||
export const MAJOR = 1
|
||||
export const MINOR = 2
|
||||
export const GROUP = '2'
|
||||
export const MAJOR = 2
|
||||
|
||||
Reference in New Issue
Block a user