Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Geng Tan
committed
Nov 26, 2021
1 parent
5fc691c
commit d619cba
Showing
1 changed file
with
8 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |