3 Commits

Author SHA1 Message Date
Aleksei Igrychev
72a1f765ae Merge pull request #73 from werf/feat/use_nodejs_20
feat: use nodejs 20
2024-02-14 15:34:26 +00:00
Aleksei Igrychev
cd8e56a2c0 Update test.yaml 2024-02-14 15:27:55 +00:00
Aleksei Igrychev
43075e4ab8 Merge pull request #72 from werf/feat/ignore_virtual_merge_init
feat: ignore initialization of virtual merge commits
2023-12-21 22:18:35 +00:00
26 changed files with 2304 additions and 3418 deletions

View File

@@ -1,6 +1,10 @@
name: Test name: Test
on: on:
push: push:
schedule:
- cron: "0 8 * * *"
workflow_dispatch:
jobs: jobs:
channel: channel:
@@ -38,6 +42,6 @@ jobs:
- name: Install - name: Install
uses: ./install uses: ./install
with: with:
version: v2.31.1 version: v1.2.35
- run: werf version - run: werf version

5
.gitignore vendored
View File

@@ -96,7 +96,4 @@ Thumbs.db
# Ignore built ts files # Ignore built ts files
__tests__/runner/* __tests__/runner/*
lib/**/* lib/**/*
# Intellij
/.idea

View File

@@ -5,7 +5,7 @@ ___
This action allows you to organize CI/CD with GitHub Actions and [werf](https://github.com/werf/werf). 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/getting_started/?usage=ci&ci=githubActions&runnerType=hostRunner&os=linux&buildBackend=buildah&projectType=simplified&sharedCICD=no&repoType=application). **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).
## How to use ## How to use
@@ -21,7 +21,7 @@ converge:
fetch-depth: 0 fetch-depth: 0
- name: Install werf - name: Install werf
uses: werf/actions/install@v2 uses: werf/actions/install@v1.2
- name: Run script - name: Run script
run: | run: |
@@ -30,12 +30,19 @@ converge:
env: env:
WERF_KUBECONFIG_BASE64: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} WERF_KUBECONFIG_BASE64: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
WERF_ENV: production WERF_ENV: production
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
## Versioning ## Versioning
When using action, select the version corresponding to the required `MAJOR` version of werf. 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
```
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)). 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. Using the `channel` input the user can switch the release channel.
@@ -43,7 +50,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. > This is recommended approach to be up-to-date and to use actual werf version without changing configurations.
```yaml ```yaml
- uses: werf/actions/install@v2 - uses: werf/actions/install@v1.2
with: with:
channel: alpha channel: alpha
``` ```
@@ -51,9 +58,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. Withal, it is not necessary to work within release channels, and the user might specify certain werf version with `version` input.
```yaml ```yaml
- uses: werf/actions/install@v2 - uses: werf/actions/install@v1.2
with: with:
version: v2.1.0 version: v1.2.9
``` ```
## FAQ ## FAQ
@@ -71,74 +78,7 @@ 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). 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 ## License

View File

@@ -7,7 +7,7 @@ branding:
inputs: inputs:
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'

View File

@@ -10,7 +10,7 @@ The action combines all the necessary steps in itself and logic may be divided i
```yaml ```yaml
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'
@@ -38,7 +38,7 @@ build:
fetch-depth: 0 fetch-depth: 0
- name: Build - name: Build
uses: werf/actions/build@v2 uses: werf/actions/build@v1.2
with: with:
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
``` ```

View File

@@ -7,7 +7,7 @@ branding:
inputs: inputs:
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ The action combines all the necessary steps in itself and logic may be divided i
```yaml ```yaml
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'
@@ -39,7 +39,7 @@ cleanup:
run: git fetch --prune --unshallow run: git fetch --prune --unshallow
- name: Cleanup - name: Cleanup
uses: werf/actions/cleanup@v2 uses: werf/actions/cleanup@v1.2
with: with:
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
env: env:

View File

@@ -7,7 +7,7 @@ branding:
inputs: inputs:
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ The action combines all the necessary steps in itself and logic may be divided i
```yaml ```yaml
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'
@@ -41,7 +41,7 @@ converge:
fetch-depth: 0 fetch-depth: 0
- name: Converge - name: Converge
uses: werf/actions/converge@v2 uses: werf/actions/converge@v1.2
with: with:
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
env: production env: production

View File

@@ -7,12 +7,12 @@ branding:
inputs: inputs:
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'
required: false required: false
env: # DEPRECATED: Use WERF_ENV environment variable instead (e.g., env: { WERF_ENV: value }) env: # TODO: Remove this deprecated werf option, which is not required anymore (use WERF_ENV variable instead)
description: 'Specific deployment environment' description: 'Specific deployment environment'
required: false required: false
github-token: github-token:

File diff suppressed because one or more lines are too long

View File

@@ -10,7 +10,7 @@ The action combines all the necessary steps in itself and logic may be divided i
```yaml ```yaml
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'
@@ -39,7 +39,7 @@ dismiss:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Dismiss - name: Dismiss
uses: werf/actions/dismiss@v2 uses: werf/actions/dismiss@v1.2
with: with:
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
env: production env: production

View File

@@ -7,7 +7,7 @@ branding:
inputs: inputs:
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'

File diff suppressed because it is too large Load Diff

View File

@@ -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 > This is recommended approach to be up-to-date and to use actual werf version without changing configurations
```yaml ```yaml
- uses: werf/actions/install@v2 - uses: werf/actions/install@v1.2
with: with:
channel: alpha 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. Withal, it is not necessary to work within release channels, and the user might specify certain werf version with `version` input.
```yaml ```yaml
- uses: werf/actions/install@v2 - uses: werf/actions/install@v1.2
with: with:
version: v2.1.0 version: v1.2.9
``` ```
## Inputs ## Inputs
@@ -27,7 +27,7 @@ Withal, it is not necessary to work within release channels, and the user might
```yaml ```yaml
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'
@@ -46,7 +46,7 @@ werf:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install werf CLI - name: Install werf CLI
uses: werf/actions/install@v2 uses: werf/actions/install@v1.2
# For deploy and distributed locks. # For deploy and distributed locks.
- name: Create kube config - name: Create kube config
@@ -63,6 +63,6 @@ werf:
werf render werf render
werf converge werf converge
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ github.token }}
WERF_ENV: production WERF_ENV: production
``` ```

View File

@@ -7,7 +7,7 @@ branding:
inputs: inputs:
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ The action combines all the necessary steps in itself and logic may be divided i
inputs: inputs:
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'
@@ -45,7 +45,7 @@ run:
fetch-depth: 0 fetch-depth: 0
- name: Run - name: Run
uses: werf/actions/run@v2 uses: werf/actions/run@v1.2
with: with:
image: backend image: backend
args: rails server args: rails server

View File

@@ -7,7 +7,7 @@ branding:
inputs: inputs:
channel: channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid' description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable' default: 'alpha'
required: false required: false
version: version:
description: 'The certain version' description: 'The certain version'

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,8 @@ import {String} from 'typescript-string-operations'
import {Manager} from './manager' import {Manager} from './manager'
import * as werf from './werf' import * as werf from './werf'
const minimalWerfVersion = 'v1.1.17'
export async function PrepareEnvironAndRunWerfCommand( export async function PrepareEnvironAndRunWerfCommand(
args: string[] args: string[]
): Promise<void> { ): Promise<void> {
@@ -65,15 +67,27 @@ export function ProcessGitHubContext(): void {
export function ValidateWerfVersion(version: string): void { export function ValidateWerfVersion(version: string): void {
const ver = semver.coerce(version) const ver = semver.coerce(version)
if (ver && ver.major === werf.MAJOR) { if (ver) {
return 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
}
} }
throw new Error( throw new Error(
String.Format( String.Format(
'werf version {0} is not supported: the version must be semver and within the MAJOR ({1})', 'werf version {0} is not supported (expected version must be equal or greater than {1})',
version.trim(), version.trim(),
werf.GROUP minimalWerfVersion
) )
) )
} }

View File

@@ -3,11 +3,7 @@ import {PrepareEnvironAndRunWerfCommand} from './common'
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
// with.env parameter has priority over WERF_ENV environment variable process.env.WERF_ENV = core.getInput('env')
const envInput = core.getInput('env')
if (envInput) {
process.env.WERF_ENV = envInput
}
await PrepareEnvironAndRunWerfCommand(['converge']) await PrepareEnvironAndRunWerfCommand(['converge'])
} catch (error) { } catch (error) {
core.setFailed(error.message) core.setFailed(error.message)

View File

@@ -125,7 +125,7 @@ export class Manager {
return this._constructReleaseUrl(version) return this._constructReleaseUrl(version)
} }
const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}` const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}`
try { try {
const resp = await request const resp = await request
.get(url) .get(url)

View File

@@ -1,2 +1,3 @@
export const GROUP = '2' export const MAJOR_MINOR_GROUP = '1.2'
export const MAJOR = 2 export const MAJOR = 1
export const MINOR = 2