Merge pull request #861 from alphagov/update-tagging #54
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
name: Deploy | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
concurrency: production | |
jobs: | |
build: | |
uses: ./.github/workflows/test.yaml | |
with: | |
upload-artifact: true | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Pre-deploy checks | |
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 | |
with: | |
script: | | |
// Check that the code to be deployed is the latest code on the branch on GitHub | |
// If you want to rollback changes to prod, consider using a revert commit to main | |
// | |
const response = await github.rest.repos.getCommit({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/heads/main', | |
}); | |
const mainBranchCommitSha = response.data.sha | |
if (context.sha !== mainBranchCommitSha) { | |
core.info(`Workflow run GITHUB_SHA ${context.sha} does not match main branch commit sha ${mainBranchCommitSha}`) | |
core.error('Code to deploy does not match code in main branch') | |
core.setFailed('Refusing to deploy, please do not re-run this workflow run') | |
} | |
- name: Checkout | |
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b | |
- name: Download build artifact | |
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 | |
with: | |
name: build | |
path: build | |
- name: add-cloudfoundry-repository | |
run: | | |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - | |
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list | |
- name: install-cloudfoundry-cli | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y cf7-cli | |
- name: deploy-to-paas | |
env: | |
CF_USERNAME: ${{ secrets.CF_EMAIL }} | |
CF_PASSWORD: ${{ secrets.CF_PASSWORD }} | |
run: | | |
cf api https://api.cloud.service.gov.uk | |
cf auth | |
cf target -o gds-tech-ops -s docs | |
cf push -f ./manifest.yml |