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..fd406dd 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@v1.0.0 publish: - uses: ./.github/workflows/_publish.yml + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v1.0.0 needs: [ validate ] secrets: inherit deploy: - uses: ./.github/workflows/_deploy.yml + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@v1.0.0 needs: [publish] secrets: inherit strategy: diff --git a/.github/workflows/pull-request-cleanup.yml b/.github/workflows/pull-request-cleanup.yml new file mode 100644 index 0000000..9545fd6 --- /dev/null +++ b/.github/workflows/pull-request-cleanup.yml @@ -0,0 +1,14 @@ +name: "Pull Request Cleanup" + +on: + pull_request: + branches: [ master ] + types: [ closed ] + +jobs: + delete-tag: + uses: aeternity/github-actions/.github/workflows/_delete-tag-docker.yml@v1.0.0 + secrets: inherit + with: + DOCKERHUB_REPO: aeternitybot/aemon + DOCKERHUB_TAG: "pr-${{ github.event.number }}" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a7a7b36..bddfa6e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,8 +6,10 @@ on: jobs: validate: - uses: ./.github/workflows/_validate.yml + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@v1.0.0 publish: - uses: ./.github/workflows/_publish.yml + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v1.0.0 needs: [ validate ] secrets: inherit + with: + DOCKERHUB_REPO: aeternitybot/aemon diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ef9a98..cf6c62f 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@v1.0.0 publish: - uses: ./.github/workflows/_publish.yml + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v1.0.0 needs: [ validate ] secrets: inherit deploy: - uses: ./.github/workflows/_deploy.yml + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@v1.0.0 needs: [publish] secrets: inherit strategy: