From 1376aaf43d7e4998ab76bac576333169669a1d21 Mon Sep 17 00:00:00 2001 From: Maxence Maireaux Date: Wed, 25 Sep 2024 22:26:46 +0200 Subject: [PATCH] ci: Add deployment step --- .github/dependabot.yml | 24 +------------------- .github/workflows/main.yml | 32 +++++++++++++++++++++++++- .github/workflows/releases.yml | 41 +++++----------------------------- Earthfile | 2 +- 4 files changed, 39 insertions(+), 60 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 77cbf46b6..696d5cf9f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -21,29 +21,7 @@ updates: go-openapi: patterns: - "github.com/go-openapi/*" - - - package-ecosystem: gomod - directory: "/ee/**" - schedule: - interval: daily - open-pull-requests-limit: 40 - labels: [ "dependencies" ] - # Groups are updated together in one pull request - groups: - otel: - patterns: - - "go.opentelemetry.io/otel*" - otel-collector: - patterns: - - "go.opentelemetry.io/collector*" - - "github.com/open-telemetry/o*-collector-contrib/*" - otel-instrumentation: - patterns: - - "go.opentelemetry.io/contrib/instrumentation/*" - go-openapi: - patterns: - - "github.com/go-openapi/*" - + - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7c1cd3ad..04e1dd3c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -112,4 +112,34 @@ jobs: GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} FURY_TOKEN: ${{ secrets.FURY_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + + Deploy: + runs-on: "ubuntu-latest" + if: github.ref == 'refs/heads/main' + environment: staging + needs: + - GoReleaser + - Tests + steps: + - uses: earthly/actions-setup@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version: "latest" + - uses: 'actions/checkout@v4' + with: + fetch-depth: 0 + - name: Tailscale + uses: tailscale/github-action@v2 + with: + oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} + oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} + tags: tag:ci + - name: "Deploy in staging" + env: + TAG: ${{ github.sha }} + run: > + earthly + --no-output + +deploy-staging + --TAG=$TAG \ No newline at end of file diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 6a2fbada2..b6dc7fbe8 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -7,43 +7,9 @@ permissions: contents: write jobs: - Dirty: - runs-on: "ubuntu-latest" - steps: - - uses: 'actions/checkout@v4' - with: - fetch-depth: 0 - - name: Setup Env - uses: ./.github/actions/env - with: - token: ${{ secrets.NUMARY_GITHUB_TOKEN }} - - run: > - earthly - --allow-privileged - --secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY - ${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }} - +pre-commit - env: - SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} - - name: Get changed files - id: changed-files - run: | - hasChanged=$(git status --porcelain) - if (( $(echo ${#hasChanged}) != 0 )); then - git status - echo "There are changes in the repository" - exit 1 - fi - GoReleaser: runs-on: "ubuntu-latest" - needs: - - Dirty steps: - - uses: earthly/actions-setup@v1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - version: "latest" - uses: 'actions/checkout@v4' with: fetch-depth: 0 @@ -71,4 +37,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }} SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} FURY_TOKEN: ${{ secrets.FURY_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + - name: Add the OpenAPI file to the release assets + run: > + gh release upload ${{github.ref_name}} ./openapi.yaml#openapi.yaml + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Earthfile b/Earthfile index 242cf74d7..85ee40ee5 100644 --- a/Earthfile +++ b/Earthfile @@ -1,7 +1,7 @@ VERSION 0.8 PROJECT FormanceHQ/ledger -IMPORT github.com/formancehq/earthly:tags/v0.16.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.16.1 AS core IMPORT github.com/formancehq/stack/releases:main AS releases FROM core+base-image