Skip to content

Commit

Permalink
Merge pull request #47 from ladesa-ro/branch-gabriel
Browse files Browse the repository at this point in the history
feat(ci): init gerar-horario-service build and push
  • Loading branch information
guesant authored Jun 20, 2024
2 parents baeaa64 + cfa2f6c commit 7f9df43
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 8 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Continuous Integration

on:
workflow_dispatch:
push:
branches:
- "development"
- "production"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CI_DEVELOPMENT_BRANCH: ${{ vars.CI_DEVELOPMENT_BRANCH }}
CI_PRODUCTION_BRANCH: ${{ vars.CI_PRODUCTION_BRANCH }}

ENABLE_BUILD_IMAGE: ${{ vars.ENABLE_BUILD_IMAGE }}
IMAGE_TAG_DEVELOPMENT: ${{ vars.IMAGE_TAG_DEVELOPMENT }}
IMAGE_TAG_PRODUCTION: ${{ vars.IMAGE_TAG_PRODUCTION }}

ENABLE_PUSH_IMAGE: ${{ vars.ENABLE_PUSH_IMAGE }}

# REGISTRY_URL: ${{ secrets.REGISTRY_URL }}
# REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
# REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
# IMAGE_NAME: ${{ vars.IMAGE_NAME }}

REGISTRY_URL: ghcr.io
REGISTRY_USERNAME: ${{ github.actor }}
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SERVICE_IMAGE_NAME: gerar-horario-service

ENABLE_TRIGGER_DEPLOY: ${{ vars.ENABLE_TRIGGER_DEPLOY }}
DEPLOY_DISPATCH_TOKEN: ${{ secrets.DEPLOY_DISPATCH_TOKEN }}
DEPLOY_OWNER: ${{ vars.DEPLOY_OWNER }}
DEPLOY_REPOSITORY: ${{ vars.DEPLOY_REPOSITORY }}
DEPLOY_WORKFLOW: ${{ vars.DEPLOY_WORKFLOW }}
DEPLOY_BRANCH: ${{ vars.DEPLOY_BRANCH }}

jobs:
image-build-push-service:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Registry
if: ${{ env.ENABLE_PUSH_IMAGE == 'true' }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_TOKEN }}

- name: Build (and push if enabled) channel development
if: ${{ env.ENABLE_BUILD_IMAGE == 'true' && github.ref_name == env.CI_DEVELOPMENT_BRANCH }}
uses: docker/build-push-action@v6
with:
file: Dockerfile.service
push: ${{ env.ENABLE_PUSH_IMAGE == 'true' }}
tags: ${{ env.REGISTRY_URL }}/${{ env.SERVICE_IMAGE_NAME }}:${{ env.IMAGE_TAG_DEVELOPMENT }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build (and push if enabled) channel production
if: ${{ env.ENABLE_BUILD_IMAGE == 'true' && github.ref_name == env.CI_PRODUCTION_BRANCH }}
uses: docker/build-push-action@v6
with:
file: Dockerfile.service
push: ${{ env.ENABLE_PUSH_IMAGE == 'true' }}
tags: ${{ env.REGISTRY_URL }}/${{ env.SERVICE_IMAGE_NAME }}:${{ env.IMAGE_TAG_PRODUCTION }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Dispatch infrastructure deploy workflow
if: ${{ env.ENABLE_BUILD_IMAGE == 'true' && env.ENABLE_PUSH_IMAGE == 'true' && env.ENABLE_TRIGGER_DEPLOY == 'true' }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ env.DEPLOY_DISPATCH_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ env.DEPLOY_OWNER }}/${{ env.DEPLOY_REPOSITORY }}/actions/workflows/${{ env.DEPLOY_WORKFLOW }}/dispatches \
-d '{"ref":"${{ env.DEPLOY_BRANCH }}","inputs":{}}'
51 changes: 43 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# gerar-horario

[![CodeQL](https://github.com/sisgha/gerar-horario/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/sisgha/gerar-horario/actions/workflows/github-code-scanning/codeql)
[![NUnit Tests + Allure Reports](https://github.com/sisgha/gerar-horario/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sisgha/gerar-horario/actions/workflows/test-and-deploy.yml)
[![CodeQL][badge-codeql-src]][badge-codeql-href]
[![NUnit Tests + Allure Reports][badge-tests-src]][badge-tests-href]

Allure Report: [`https://sisgha.github.io/gerar-horario`](https://sisgha.github.io/gerar-horario).
Allure Report: [clique aqui][tests-allure-report].

## Desenvolvimento
## Ambientes

### Produção

[![CI Production][action-ci-prod-src]][action-ci-prod-href]

### Desenvolvimento

[![CI Development][action-ci-dev-src]][action-ci-dev-href]

## Configuração Local

```sh
git clone https://github.com/sisgha/gerar-horario.git;
git clone https://github.com/ladesa-ro/gerar-horario.git
cd gerar-horario
```

### Projeto Gerar Horário
Expand All @@ -35,13 +46,37 @@ Continue em [`./Playground/README.md`](./Playground/README.md).
git checkout estudo-ts;
```

- Estudo Node Z3: [`tree/estudo-ts/estudo/estudo-node-z3/projeto`](https://github.com/sisgha/gerar-horario/tree/estudo-ts/estudo/estudo-node-z3/projeto);
- Estudo CSharp Or-Tools: [`tree/estudo-ts/estudo/estudo-csharp/dotnet-project`](https://github.com/sisgha/gerar-horario/tree/estudo-ts/estudo/estudo-csharp/dotnet-project);
- Estudo Node Z3: [`tree/estudo-ts/estudo/estudo-node-z3/projeto`][estudo-node-z3];
- Estudo CSharp Or-Tools: [`tree/estudo-ts/estudo/estudo-csharp/dotnet-project`][estudo-csharp-ortools];

Continue em [`tree/estudo-ts/README.md`](https://github.com/sisgha/gerar-horario/blob/estudo-ts/README.md).
Continue em [`tree/estudo-ts/README.md`][estudo].

## Licença

[MIT - Gabriel R. Antunes, 2024](./LICENSE).

[MIT - Ladesa e Contribuidores, 2024](./LICENSE).

<!-- Badges -->

[badge-codeql-src]: https://github.com/ladesa-ro/gerar-horario/actions/workflows/github-code-scanning/codeql/badge.svg
[badge-codeql-href]: https://github.com/ladesa-ro/gerar-horario/actions/workflows/github-code-scanning/codeql
[badge-tests-src]: https://github.com/ladesa-ro/gerar-horario/actions/workflows/test-and-deploy.yml/badge.svg
[badge-tests-href]: https://github.com/ladesa-ro/gerar-horario/actions/workflows/test-and-deploy.yml
[tests-allure-report]: https://ladesa-ro.github.io/gerar-horario

<!-- Badges / Actions / Production -->

[action-ci-prod-src]: https://img.shields.io/github/actions/workflow/status/ladesa-ro/gerar-horario/ci.yml?style=flat&logo=github&logoColor=white&label=CI@production&branch=production&labelColor=18181B
[action-ci-prod-href]: https://github.com/ladesa-ro/gerar-horario/actions/workflows/ci.yml?query=branch%3Aproduction

<!-- Badges / Actions / Development -->

[action-ci-dev-src]: https://img.shields.io/github/actions/workflow/status/ladesa-ro/gerar-horario/ci.yml?style=flat&logo=github&logoColor=white&label=CI@development&branch=development&labelColor=18181B
[action-ci-dev-href]: https://github.com/ladesa-ro/gerar-horario/actions/workflows/ci.yml?query=branch%3Adevelopment

<!-- Estudo -->

[estudo]: https://github.com/ladesa-ro/gerar-horario/blob/estudo-ts/README.md
[estudo-node-z3]: https://github.com/ladesa-ro/gerar-horario/tree/estudo-ts/estudo/estudo-node-z3/projeto
[estudo-csharp-ortools]: https://github.com/ladesa-ro/gerar-horario/tree/estudo-ts/estudo/estudo-csharp/dotnet-project

0 comments on commit 7f9df43

Please sign in to comment.