From bbfa39654b32e1847f81b1a2fb4b9a95a41dc137 Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 14:40:24 +0200 Subject: [PATCH] Switch all WFs to shared --- .github/workflows/_deploy.yml | 82 ------------------------------ .github/workflows/_publish.yml | 37 -------------- .github/workflows/_validate.yml | 20 -------- .github/workflows/mainline.yml | 6 +-- .github/workflows/pull-request.yml | 7 +-- .github/workflows/release.yml | 6 +-- 6 files changed, 8 insertions(+), 150 deletions(-) delete mode 100644 .github/workflows/_deploy.yml delete mode 100644 .github/workflows/_publish.yml delete mode 100644 .github/workflows/_validate.yml diff --git a/.github/workflows/_deploy.yml b/.github/workflows/_deploy.yml deleted file mode 100644 index ec66d0a..0000000 --- a/.github/workflows/_deploy.yml +++ /dev/null @@ -1,82 +0,0 @@ -on: - workflow_call: - inputs: - DEPLOY_REPO: - description: 'Gitops repository used to deploy' - type: string - default: aeternity/gitops-apps - DEPLOY_APP: - description: 'Deploy application in gitops repository, usually the caller repository name' - type: string - default: ${{ github.event.repository.name }} - DEPLOY_ENV: - description: 'Deploy environment name to deploy to' - type: string - required: true - DEPLOY_VERSION: - description: 'Application version to deploy' - type: string - required: false - DEPLOY_TAG: - description: 'Application tag to deploy' - type: string - required: false - DEPLOY_HOST_PREFIX: - description: 'Deployment hostname prefix, usually $VERSION-' - type: string - required: false - -jobs: - deploy: - name: "Deploy to Gitops" - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - repository: ${{ inputs.DEPLOY_REPO }} - token: ${{ secrets.BOT_GITHUB_TOKEN }} - ref: ${{ inputs.DEPLOY_ENV }} - persist-credentials: false - fetch-depth: 0 - - - name: Configure git - shell: bash - run: | - git config --local user.email "aeternity-bot@users.noreply.github.com" - git config --local user.name "github-actions" - - - name: Update application version in Gitops repository - if: ${{ inputs.DEPLOY_VERSION != '' }} - shell: bash - env: - APP_ENV: ${{ inputs.DEPLOY_ENV }} - APP_VERSION: ${{ inputs.DEPLOY_VERSION }} - APP_HOST_PREFIX: ${{ inputs.DEPLOY_HOST_PREFIX }} - APP_VERSION_SHA_LONG: ${{ github.sha }} - run: | - export APP_VERSION_SHA=${APP_VERSION_SHA_LONG:0:7} - ./scripts/app.sh update-version ${{ inputs.DEPLOY_APP }} - - - name: Update application tag in Gitops repository - if: ${{ inputs.DEPLOY_TAG != '' }} - shell: bash - env: - APP_ENV: ${{ inputs.DEPLOY_ENV }} - APP_VERSION: ${{ inputs.DEPLOY_TAG }} - run: | - ./scripts/app.sh update-tag ${{ inputs.DEPLOY_APP }} - - - name: Commit Gitops changes - shell: bash - env: - APP_VERSION: ${{ inputs.DEPLOY_TAG || inputs.DEPLOY_VERSION }} - run: | - git add . - git commit -m "Deploy ${{ inputs.DEPLOY_APP }} to ${{ inputs.DEPLOY_ENV }} - ${APP_VERSION} (sha: ${{ github.sha }})" - - - name: Push changes - uses: ad-m/github-push-action@master - with: - repository: ${{ inputs.DEPLOY_REPO }} - github_token: ${{ secrets.BOT_GITHUB_TOKEN }} - branch: ${{ inputs.DEPLOY_ENV }} diff --git a/.github/workflows/_publish.yml b/.github/workflows/_publish.yml deleted file mode 100644 index 78cc3d4..0000000 --- a/.github/workflows/_publish.yml +++ /dev/null @@ -1,37 +0,0 @@ -on: - workflow_call: - secrets: - DOCKERHUB_USER: - required: true - DOCKERHUB_PASS: - required: true - -jobs: - dockerhub: - name: "Publish to Dockehub" - runs-on: ubuntu-20.04 - steps: - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: | - ${{ github.repository }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern=v{{version}} - - - name: Login to Dockerhub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_PASS }} - - - name: Build and push docker image - uses: docker/build-push-action@v4 - if: ${{ steps.meta.outputs.tags }} - with: - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/_validate.yml b/.github/workflows/_validate.yml deleted file mode 100644 index aa4584e..0000000 --- a/.github/workflows/_validate.yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - workflow_call: - -jobs: - build_test: - runs-on: ubuntu-20.04 - strategy: - matrix: - node-version: [18.x] - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: npm - - run: npm config set fund false - - run: npm install - - run: npm run lint - - run: npm run test diff --git a/.github/workflows/mainline.yml b/.github/workflows/mainline.yml index 50efe1f..f5a216d 100644 --- a/.github/workflows/mainline.yml +++ b/.github/workflows/mainline.yml @@ -6,13 +6,13 @@ on: jobs: validate: - uses: ./.github/workflows/_validate.yml + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml publish: - uses: ./.github/workflows/_publish.yml + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml needs: [ validate ] secrets: inherit deploy: - uses: ./.github/workflows/_deploy.yml + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml needs: [publish] secrets: inherit strategy: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 34c39c9..96ad918 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,13 +4,10 @@ on: pull_request: branches: [ master ] -env: - GH_WORKFLOWS: aeternity/github-actions/.github/workflows - jobs: validate: - uses: ${{ env.GH_WORKFLOWS }}/_validate-npm.yml@master + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master publish: - uses: ${{ env.GH_WORKFLOWS }}/_publish-docker.yml@master + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master needs: [ validate ] secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ef9a98..28773e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,13 +6,13 @@ on: jobs: validate: - uses: ./.github/workflows/_validate.yml + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master publish: - uses: ./.github/workflows/_publish.yml + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master needs: [ validate ] secrets: inherit deploy: - uses: ./.github/workflows/_deploy.yml + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@master needs: [publish] secrets: inherit strategy: