-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
251 additions
and
175 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,68 @@ | ||
name: Build and push docker image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
DEPLOY_ENV: | ||
description: 'The environment to deploy to' | ||
required: true | ||
type: string | ||
|
||
RUST_VERSION: | ||
description: The Rust version to use | ||
required: true | ||
type: string | ||
|
||
IMAGE_NAME: | ||
description: The name of the image to build | ||
required: true | ||
type: string | ||
|
||
outputs: | ||
DOCKER_IMAGE: | ||
description: Name of Docker image | ||
value: ${{ jobs.build-and-push-image.outputs.DOCKER_IMAGE }} | ||
|
||
env: | ||
DOCKER_REGISTRY: ghcr.io | ||
DOCKER_IMAGE: ${{ github.repository }}/${{ github.event.inputs.RUST_VERSION }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
if: inputs.DEPLOY_ENV == 'production' | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
DOCKER_IMAGE: ${{ steps.docker-meta.outputs.tags }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to the container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.DOCKER_REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker meta-data | ||
id: docker-meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
build-args: | | ||
RUST_VERSION=${{ inputs.RUST_VERSION }} | ||
tags: ${{ steps.docker-meta.outputs.tags }} | ||
labels: ${{ steps.docker-meta.outputs.labels }} | ||
cache-from: type=registry,ref=user/app:latest | ||
cache-to: type=inline |
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
name: CD | ||
name: Deploy app | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- CI | ||
branches: | ||
- main | ||
types: | ||
- completed | ||
workflow_call: | ||
inputs: | ||
DOCKER_IMAGE: | ||
description: 'Path to the image' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
CD: | ||
name: Deploy app | ||
deploy-app: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
|
||
- run: flyctl deploy --remote-only | ||
- run: | | ||
flyctl deploy --remote-only --image ${{ env.DOCKER_IMAGE }} | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
DOCKER_IMAGE: ${{ github.event.inputs.DOCKER_IMAGE }} |
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,37 @@ | ||
name: Lint project | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
RUST_VERSION: | ||
description: Rust version to use for the workflow | ||
type: string | ||
|
||
jobs: | ||
lint-project: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Rust environment | ||
run: | | ||
rustup update | ||
rustup install ${{ inputs.RUST_VERSION }} | ||
rustup default ${{ inputs.RUST_VERSION }} | ||
rustup component add clippy | ||
- name: Add WASM target | ||
run: | | ||
rustup target add wasm32-unknown-unknown | ||
- name: Write toolchain info | ||
run: | | ||
cargo --version --verbose | ||
rustc --version | ||
cargo clippy --version | ||
- name: Lint Rust code wiht Clippy | ||
run: | | ||
cargo clippy --all-targets --all-features -- |
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,38 @@ | ||
name: Project ipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
paths-ignore: | ||
- 'LICENSE' | ||
- 'README.md' | ||
- 'CHANGELOG.md' | ||
|
||
jobs: | ||
prepare: | ||
uses: ./.github/workflows/prepare.yml | ||
secrets: inherit | ||
|
||
linter: | ||
uses: ./.github/workflows/linter.yml | ||
needs: [prepare] | ||
secrets: inherit | ||
with: | ||
RUST_VERSION: ${{ needs.prepare.outputs.RUST_VERSION }} | ||
|
||
build: | ||
uses: ./.github/workflows/build.yml | ||
needs: [prepare, linter] | ||
secrets: inherit | ||
with: | ||
DEPLOY_ENV: ${{ needs.prepare.outputs.DEPLOY_ENV }} | ||
RUST_VERSION: ${{ needs.prepare.outputs.RUST_VERSION }} | ||
IMAGE_NAME: ${{ needs.prepare.outputs.IMAGE_NAME }} | ||
|
||
deploy: | ||
needs: [prepare, linter, build] | ||
uses: ./.github/workflows/deploy.yml | ||
secrets: inherit | ||
with: | ||
DOCKER_IMAGE: ${{ needs.build.outputs.DOCKER_IMAGE }} |
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,83 @@ | ||
name: Prepare pipeline | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
DEPLOY_ENV: | ||
description: What kind of deployment this is | ||
value: ${{ jobs.prepare-pipeline.outputs.DEPLOY_ENV }} | ||
|
||
RUST_VERSION: | ||
description: The version of Rust to use | ||
value: ${{ jobs.prepare-pipeline.outputs.RUST_ENV }} | ||
|
||
IMAGE_NAME: | ||
description: The name of the image to build | ||
value: ${{ jobs.prepare-pipeline.outputs.IMAGE_NAME }} | ||
|
||
jobs: | ||
prepare-pipeline: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
DEPLOY_ENV: ${{ steps.deploy-env.outputs.DEPLOY_ENV }} | ||
RUST_ENV: ${{ steps.rust-version.outputs.RUST_VERSION }} | ||
IMAGE_NAME: ${{ steps.image-name.outputs.IMAGE_NAME }} | ||
|
||
steps: | ||
- name: Set deployment variable | ||
id: deploy-env | ||
env: | ||
BRANCH: ${{ github.ref_name }} | ||
run: | | ||
if [[ $BRANCH == "main" || $BRANCH == "master" ]]; then | ||
DEPLOY_ENV=PROD | ||
elif [[ $BRANCH == "staging" ]]; then | ||
DEPLOY_ENV=STAGING | ||
else | ||
DEPLOY_ENV=TEST | ||
fi | ||
echo "DEPLOY_ENV="$DEPLOY_ENV | ||
echo "DEPLOY_ENV=$DEPLOY_ENV" >> $GITHUB_OUTPUT | ||
- name: Set Rust version | ||
id: rust-version | ||
env: | ||
RUST_VERSION: ${{ vars.RUST_VERSION }} | ||
run: | | ||
if [[ -n "$RUST_VERSION" ]]; then | ||
RUST_VERSION=$RUST_VERSION | ||
else | ||
RUST_VERSION=stable | ||
fi | ||
echo "RUST_VERSION="$RUST_VERSION | ||
echo "RUST_VERSION=$RUST_VERSION" >> $GITHUB_OUTPUT | ||
- name: Set image name | ||
id : image-name | ||
env: | ||
GIT_REPOSITORY: ${{ github.repository }} | ||
run: | | ||
IMAGE_NAME=$GIT_REPOSITORY | ||
echo "IMAGE_NAME="$IMAGE_NAME | ||
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_OUTPUT | ||
- name: Write prepare summary | ||
run: | | ||
echo '### Prepare pipeline: | ||
<table> | ||
<tr> | ||
<td>🎯 Deploy env</td> | ||
<td>${{ steps.deploy-env.outputs.DEPLOY_ENV }}</td> | ||
</tr> | ||
<tr> | ||
<td>🦀 Rust version</td> | ||
<td>${{ steps.rust-version.outputs.RUST_VERSION }}</td> | ||
</tr> | ||
<tr> | ||
<td>🐳 Image name</td> | ||
<td>${{ steps.image-name.outputs.IMAGE_NAME }}</td> | ||
</tr> | ||
</table>' >> $GITHUB_STEP_SUMMARY |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.