Repository navigation
Deploy #93
This file contains hidden or 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: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: "Environment (test/prod)" | |
| required: true | |
| default: "test" | |
| source_tag: | |
| description: "Source tag to promote" | |
| required: true | |
| default: "latest" | |
| defaults: | |
| run: | |
| shell: bash | |
| working-directory: ./ | |
| jobs: | |
| deployment: | |
| runs-on: ubuntu-22.04 | |
| environment: | |
| name: ${{ github.event.inputs.environment }} | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Login Openshift | |
| shell: bash | |
| run: | | |
| oc login --server=${{secrets.OPENSHIFT_LOGIN_REGISTRY}} --token=${{secrets.OPENSHIFT_SA_TOKEN}} | |
| - name: Backup Current Images | |
| shell: bash | |
| run: | | |
| oc project ${{ secrets.OPENSHIFT_REPOSITORY }}-tools | |
| TIMESTAMP=$(date +%Y%m%d-%H%M%S) | |
| oc tag submit-api:${{ github.event.inputs.environment }} submit-api:backup-${{ github.event.inputs.environment }}-$TIMESTAMP | |
| oc tag submit-web:${{ github.event.inputs.environment }} submit-web:backup-${{ github.event.inputs.environment }}-$TIMESTAMP | |
| echo "Backup tags created with timestamp: $TIMESTAMP" | |
| - name: Tag Images and Rollout | |
| shell: bash | |
| run: | | |
| oc project ${{ secrets.OPENSHIFT_REPOSITORY }}-tools | |
| oc tag submit-api:${{ github.event.inputs.source_tag }} submit-api:${{ github.event.inputs.environment }} | |
| oc tag submit-web:${{ github.event.inputs.source_tag }} submit-web:${{ github.event.inputs.environment }} | |
| oc rollout restart deployment/submit-api -n ${{ secrets.OPENSHIFT_REPOSITORY }}-${{ github.event.inputs.environment }} | |
| oc rollout restart deployment/submit-web -n ${{ secrets.OPENSHIFT_REPOSITORY }}-${{ github.event.inputs.environment }} |