From d619cba5fc1f5e930d7a682fd36ff6e5166f3a51 Mon Sep 17 00:00:00 2001 From: Geng Tan Date: Fri, 26 Nov 2021 11:59:57 -0500 Subject: [PATCH] adding reusableTurkeyGitOps --- .github/workflows/hubs-RetPageOrigin.yml | 91 +++--------------------- 1 file changed, 8 insertions(+), 83 deletions(-) diff --git a/.github/workflows/hubs-RetPageOrigin.yml b/.github/workflows/hubs-RetPageOrigin.yml index f8857d963e..7a3aecacf8 100644 --- a/.github/workflows/hubs-RetPageOrigin.yml +++ b/.github/workflows/hubs-RetPageOrigin.yml @@ -1,90 +1,15 @@ name: hubs on: push: + branches: paths-ignore: ["README.md"] workflow_dispatch: -env: - registryName: mozillareality - containerName: hubs - jobs: - build: - runs-on: ubuntu-latest - steps: - - name: checkout-hubs - uses: actions/checkout@v2 - with: - path: "./hubs" - - name: docker setup buildx - uses: docker/setup-buildx-action@v1 - with: - install: true - - name: docker login - uses: docker/login-action@v1 - with: - username: ${{ env.registryName }} - password: ${{ secrets.DOCKER_HUB_PWD }} - - name: docker build(x) push - uses: docker/build-push-action@v2 - with: - context: hubs/ - file: hubs/RetPageOriginDockerfile - tags: ${{ env.registryName }}/${{ env.containerName }}:${{ github.run_number }} - cache-from: type=registry,ref=${{ env.registryName }}/${{ env.containerName }}:buildcache - cache-to: type=registry,ref=${{ env.registryName }}/${{ env.containerName }}:buildcache,mode=max - push: true - - # turkeyGitops: - # needs: build - # uses: mozilla/hubs-ops/.github/workflows/turkeyGitops.yml@feature/gha-template - # with: - # promoteFrom: mozillareality/hubs:${{ github.run_number }} - # promoteTo: mozillareality/hubs:${GITHUB_REF/'refs/heads/'/} - # # https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#limitations - # # Any environment variables set in an env context defined at the workflow level in the caller workflow are not propagated to the called workflow. - # # promoteFrom: ${{ env.registryName }}/${{ env.containerName }}:${{ github.run_number }} - # # promoteTo: ${{ env.registryName }}/${{ env.containerName }}:${GITHUB_REF/'refs/heads/'/} - - promote: - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/prod' - runs-on: ubuntu-latest - needs: build - steps: - - name: promote artifact - run: | - fromTag=${{ env.registryName }}/${{ env.containerName }}:${{ github.run_number }} - toTag=${{ env.registryName }}/${{ env.containerName }}:${GITHUB_REF/'refs/heads/'/} - toTag=${toTag//:master/:dev} - echo "promoting :$fromTag to :$toTag" - echo ${{ secrets.DOCKER_HUB_PWD }} | sudo docker login --username $registryName --password-stdin - docker pull $fromTag && docker tag $fromTag $toTag && sudo docker push $toTag - - staging_pr_to_prod: - if: github.ref == 'refs/heads/staging' - runs-on: ubuntu-latest - needs: promote - steps: - - name: checkout-hubs - uses: actions/checkout@v2 - with: - path: ./hubs_staging - - name: create pr for staging -> prod - run: | - cd ./hubs_staging - GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} gh pr create -H staging -B prod -a tanfarming --title "releasing" --body "note: merge this PR == production release" - - prod_cut_release_branch: - if: github.ref == 'refs/heads/prod' - runs-on: ubuntu-latest - needs: promote - steps: - - name: checkout-hubs - uses: actions/checkout@v2 - with: - path: ./hubs_prod - - name: cut release branch for prod - run: | - cd ./hubs_prod - branchName="releases/$(date '+%y%m%d').$GITHUB_RUN_NUMBER" - git checkout -b $branchName && git push origin $branchName + turkeyGitops: + uses: mozilla/hubs-ops/.github/workflows/turkeyGitops.yml@master + with: + registry: mozillareality + dockerfile: RetPageOriginDockerfile + secrets: + DOCKER_HUB_PWD: ${{ secrets.DOCKER_HUB_PWD }}