fix issue confusing head vs base branch syntax (#377)

* fix issue confusing head vs base branch syntax

* try to add pr comments
This commit is contained in:
Logan McDonald 2023-01-20 14:02:39 -08:00 committed by GitHub
parent 76d2810a8a
commit bed87212d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 24 deletions

View file

@ -8,28 +8,30 @@ on:
paths-ignore: paths-ignore:
- 'docs/**' - 'docs/**'
branches:
- 'ik/**'
- 'sspj/**'
- 'lmm/**'
- 'nmb/**'
- 'mr/**'
jobs: jobs:
variables:
outputs:
environment: ${{ steps.var.outputs.environment}}
runs-on: "ubuntu-latest"
steps:
- name: Setting global variables
uses: actions/github-script@v6
id: var
with:
script: |
core.setOutput('environment', '${{ github.head_ref }}'.split("/")[0]);
deploy: deploy:
if: |
${{startsWith(github.head_ref, 'ik/')
|| startsWith(github.head_ref, 'sspj/')
|| startsWith(github.head_ref, 'mr/')
|| startsWith(github.head_ref, 'nmb/')
|| startsWith(github.head_ref, 'lmm/')
}}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [variables]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Split branch name
env:
BRANCH: ${{ github.ref_name }}
id: split
run: echo "::set-output name=fragment::${BRANCH##*/}"
- name: Set secrets
id: secret
run: |
echo "::set-output name=cf_username::CF_${{ steps.split.outputs.fragment }}_USERNAME"
echo "::set-output name=cf_password::CF_${{ steps.split.outputs.fragment }}_PASSWORD"
- name: Compile USWDS assets - name: Compile USWDS assets
working-directory: ./src working-directory: ./src
run: | run: |
@ -43,9 +45,28 @@ jobs:
uses: 18f/cg-deploy-action@main uses: 18f/cg-deploy-action@main
env: env:
DEPLOY_NOW: thanks DEPLOY_NOW: thanks
ENVIRONMENT: ${{ needs.variables.outputs.environment }}
CF_USERNAME: CF_${{ needs.variables.outputs.environment }}_USERNAME
CF_PASSWORD: CF_${{ needs.variables.outputs.environment }}_PASSWORD
with: with:
cf_username: ${{ secrets[steps.secret.outputs.cf_username] }} cf_username: ${{ secrets[env.CF_USERNAME] }}
cf_password: ${{ secrets[steps.secret.outputs.cf_password] }} cf_password: ${{ secrets[env.CF_PASSWORD] }}
cf_org: cisa-getgov-prototyping cf_org: cisa-getgov-prototyping
cf_space: ${{ steps.split.outputs.fragment }} cf_space: ${{ env.ENVIRONMENT }}
push_arguments: "-f ops/manifests/manifest-${{ steps.split.outputs.fragment }}.yaml" push_arguments: "-f ops/manifests/manifest-${{ env.ENVIRONMENT }}.yaml"
comment:
runs-on: ubuntu-latest
needs: [variables, deploy]
steps:
- uses: actions/github-script@v6
env:
ENVIRONMENT: ${{ needs.variables.outputs.environment }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🥳 Successfully deployed to developer sandbox **[${{ env.ENVIRONMENT }}](https://getgov-${{ env.ENVIRONMENT }}.app.cloud.gov/)**.'
})

View file

@ -113,8 +113,8 @@ sed -i '' '/ - stable/ {a\
- '"$1"' - '"$1"'
}' .github/workflows/migrate.yaml }' .github/workflows/migrate.yaml
sed -i '' '/ branches:/ {a\ sed -i '' '/${{startsWith(github.head_ref, / {a\
- '"'$1/**'"' || startsWith(github.head_ref, '"'$1'"')
}' .github/workflows/deploy-sandbox.yaml }' .github/workflows/deploy-sandbox.yaml
echo "Creating space deployer for Github deploys..." echo "Creating space deployer for Github deploys..."

View file

@ -49,7 +49,6 @@ rm ops/manifests/manifest-$1.yaml
sed -i '' "/getgov-$1.app.cloud.gov/d" src/registrar/config/settings.py sed -i '' "/getgov-$1.app.cloud.gov/d" src/registrar/config/settings.py
sed -i '' "/- $1/d" .github/workflows/reset-db.yaml sed -i '' "/- $1/d" .github/workflows/reset-db.yaml
sed -i '' "/- $1/d" .github/workflows/migrate.yaml sed -i '' "/- $1/d" .github/workflows/migrate.yaml
sed -i '' "/- $1/d" .github/workflows/deploy-sandbox.yaml
echo "Cleaning up services, applications, and the Cloud.gov space for $1..." echo "Cleaning up services, applications, and the Cloud.gov space for $1..."
cf delete getgov-$1 cf delete getgov-$1