From 7da95027d8fe59e9b4936b6016bcf4f74a992884 Mon Sep 17 00:00:00 2001 From: Maxence Maireaux Date: Wed, 25 Sep 2024 22:26:52 +0200 Subject: [PATCH] ci: Add deployment step --- .github/workflows/main.yml | 32 +++++++++++++++++++++++++- .github/workflows/releases.yml | 41 +++++----------------------------- Earthfile | 2 +- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7c1cd3a..04e1dd3c 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 6a2fbada..b6dc7fbe 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 21b24062..b3b5bdb1 100644 --- a/Earthfile +++ b/Earthfile @@ -1,7 +1,7 @@ VERSION 0.8 PROJECT FormanceHQ/payments -IMPORT github.com/formancehq/earthly:tags/v0.16.0 AS core +IMPORT github.com/formancehq/earthly:tags/v0.16.1 AS core FROM core+base-image