forked from equinor/isar-exr
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
319 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Deploy to Development | ||
|
||
# Only one workflow in a concurrency group may run at a time | ||
concurrency: | ||
group: development-concurrency | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
trigger-github-deployment: | ||
name: Trigger GitHub Deployment | ||
environment: Development | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Empty Step | ||
run: echo "Hello World" | ||
|
||
get-short-sha: | ||
needs: trigger-github-deployment | ||
outputs: | ||
tag: ${{ steps.get-tag.outputs.tag }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: get-tag | ||
run: | | ||
SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-8) | ||
echo "tag=$SHA_SHORT" >> "$GITHUB_OUTPUT" | ||
build-and-push-components: | ||
name: Build and push containers to auroradevcr for Development | ||
needs: [get-short-sha, trigger-github-deployment] | ||
uses: ./.github/workflows/publish_component.yml | ||
with: | ||
Registry: auroradevacr.azurecr.io | ||
ImageName: robotics/isar-exr | ||
Tag: ${{ needs.get-short-sha.outputs.tag }} | ||
secrets: | ||
RegistryUsername: ${{ secrets.ROBOTICS_ACRPUSH_DOCKER_APPLICATION_ID }} | ||
RegistryPassword: ${{ secrets.ROBOTICS_ACRPUSH_DOCKER_SECRET }} | ||
|
||
deploy: | ||
name: Update deployment in Development | ||
needs: [build-and-push-components, get-short-sha, trigger-github-deployment] | ||
uses: ./.github/workflows/update_aurora_deployment.yml | ||
with: | ||
Environment: development | ||
Registry: auroradevacr.azurecr.io | ||
ImageName: robotics/isar-exr | ||
Tag: ${{ needs.get-short-sha.outputs.tag }} | ||
AuthorEmail: ${{ github.event.head_commit.author.email }} | ||
AuthorName: ${{ github.event.head_commit.author.name }} | ||
secrets: | ||
DeployKey: ${{ secrets.ROBOTICS_INFRASTRUCTURE_DEPLOY_KEY }} |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Deploy to Staging | ||
|
||
# Only one workflow in a concurrency group may run at a time | ||
concurrency: | ||
group: staging-concurrency | ||
cancel-in-progress: true | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
trigger-github-deployment: | ||
name: Trigger GitHub Deployment | ||
environment: Staging | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Empty Step | ||
run: echo "Hello World" | ||
|
||
build-and-push-release-to-dev: | ||
name: Update container in dev with version tag | ||
needs: trigger-github-deployment | ||
uses: ./.github/workflows/publish_component.yml | ||
with: | ||
Registry: auroradevacr.azurecr.io | ||
ImageName: robotics/isar-exr | ||
Tag: ${{ github.event.release.tag_name }} | ||
secrets: | ||
RegistryUsername: ${{ secrets.ROBOTICS_ACRPUSH_DOCKER_APPLICATION_ID }} | ||
RegistryPassword: ${{ secrets.ROBOTICS_ACRPUSH_DOCKER_SECRET }} | ||
|
||
build-and-push-components: | ||
name: Build and push container to auroraprodcr for Staging/Production | ||
needs: [trigger-github-deployment] | ||
uses: ./.github/workflows/publish_component.yml | ||
with: | ||
Registry: auroraprodacr.azurecr.io | ||
ImageName: robotics/isar-exr | ||
Tag: ${{ github.event.release.tag_name }} | ||
secrets: | ||
RegistryUsername: ${{ secrets.ROBOTICS_ACRPUSH_DOCKER_APPLICATION_ID }} | ||
RegistryPassword: ${{ secrets.ROBOTICS_ACRPUSH_DOCKER_SECRET }} | ||
|
||
deploy: | ||
name: Update deployment in Staging | ||
needs: [trigger-github-deployment, build-and-push-components] | ||
uses: ./.github/workflows/update_aurora_deployment.yml | ||
with: | ||
Environment: staging | ||
Registry: auroraprodacr.azurecr.io | ||
ImageName: robotics/isar-exr | ||
Tag: ${{ github.event.release.tag_name }} | ||
AuthorName: ${{ github.event.release.author.login }} | ||
secrets: | ||
DeployKey: ${{ secrets.ROBOTICS_INFRASTRUCTURE_DEPLOY_KEY }} |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Promote to Production | ||
|
||
# Only one workflow in a concurrency group may run at a time | ||
concurrency: | ||
group: production-concurrency | ||
cancel-in-progress: true | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
trigger-github-deployment: | ||
name: Trigger GitHub Deployment | ||
environment: Production | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Empty Step | ||
run: echo "Hello World" | ||
|
||
get_staging_version: | ||
name: Get version from staging | ||
needs: trigger-github-deployment | ||
outputs: | ||
versionTag: ${{ steps.get_version_tag.outputs.tag }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout infrastructure | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: main | ||
repository: equinor/robotics-infrastructure | ||
ssh-key: ${{ secrets.ROBOTICS_INFRASTRUCTURE_DEPLOY_KEY }} | ||
|
||
- name: Get Isar-Exr version in staging | ||
id: get_version_tag | ||
run: | | ||
LINE_NUMBERS=($(grep -n "auroraprodacr.azurecr.io/robotics/isar-exr" "k8s_kustomize/overlays/staging/kustomization.yaml" | cut -d ':' -f 1)) | ||
largest_version_int=0 | ||
largest_version_tag= | ||
for line_number in "${LINE_NUMBERS[@]}" | ||
do | ||
TAG_LINE_NUMBER=$((line_number+1)) | ||
version_tag=$(sed -n "${TAG_LINE_NUMBER}p" k8s_kustomize/overlays/staging/kustomization.yaml | cut --delimiter=":" --fields=2) | ||
version_int=$(echo "$version_tag" | tr -d '.' | tr -d '\n' | tr -d '\r' | tr -d 'v') | ||
if [[ "$version_int" -gt "$largest_version_int" ]]; then | ||
largest_version_tag=$version_tag | ||
largest_version_int=$version_int | ||
fi | ||
done | ||
echo "tag=$largest_version_tag" >> "$GITHUB_OUTPUT" | ||
deploy: | ||
name: Update deployment in Production | ||
needs: [get_staging_version, trigger-github-deployment] | ||
uses: ./.github/workflows/update_aurora_deployment.yml | ||
with: | ||
Environment: production | ||
Tag: ${{ needs.get_staging_version.outputs.versionTag }} | ||
Registry: auroraprodacr.azurecr.io | ||
ImageName: robotics/isar-exr | ||
AuthorName: ${{ github.actor }} | ||
secrets: | ||
DeployKey: ${{ secrets.ROBOTICS_INFRASTRUCTURE_DEPLOY_KEY }} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Build and publish component | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
Registry: | ||
required: true | ||
type: string | ||
Tag: | ||
required: true | ||
type: string | ||
ImageName: | ||
required: true | ||
type: string | ||
secrets: | ||
RegistryUsername: | ||
required: true | ||
RegistryPassword: | ||
required: true | ||
|
||
jobs: | ||
build-and-push-container: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to the Github Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ inputs.Registry }} | ||
username: ${{ secrets.RegistryUsername }} | ||
password: ${{ secrets.RegistryPassword }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ inputs.Registry }}/${{ inputs.ImageName }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: | | ||
${{ inputs.Registry }}/${{ inputs.ImageName }}:${{ inputs.Tag }} | ||
${{ inputs.Registry }}/${{ inputs.ImageName }}:latest | ||
labels: ${{ steps.meta.outputs.labels }} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. | ||
# | ||
# You can adjust the behavior by modifying this file. | ||
# For more information, see: | ||
# https://github.com/actions/stale | ||
name: Mark stale issues and pull requests | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '35 8 * * *' | ||
|
||
jobs: | ||
stale: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Close Stale Issues | ||
uses: actions/[email protected] | ||
with: | ||
repo-token: ${{ secrets.STALE_ISSUE_TOKEN }} | ||
stale-issue-message: 'This issue has automatically been marked as stale as there has been no activity for 60 days. Remove stale label or comment or this will be closed in 7 days.' | ||
stale-pr-message: 'This pull request has automatically been marked as stale as there has been no activity for 30 days. Remove stale label or comment or this will be closed in 7 days.' | ||
stale-issue-label: 'stale' | ||
stale-pr-label: 'stale' | ||
close-issue-message: 'This issue has been closed automatically due to a lack of activity.' | ||
close-pr-message: 'This pull request has been closed automatically due to a lack of activity.' | ||
days-before-pr-stale: 30 | ||
days-before-close: -1 |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Update deployment in aurora | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
Environment: | ||
required: true | ||
type: string | ||
Tag: | ||
required: true | ||
type: string | ||
Registry: | ||
required: true | ||
type: string | ||
ImageName: | ||
required: true | ||
type: string | ||
AuthorEmail: | ||
required: false | ||
type: string | ||
AuthorName: | ||
required: true | ||
type: string | ||
secrets: | ||
DeployKey: | ||
required: true | ||
|
||
jobs: | ||
deploy: | ||
name: Update deployment | ||
runs-on: ubuntu-latest | ||
env: | ||
EMAIL: ${{ inputs.AuthorEmail }} | ||
NAME: ${{ inputs.AuthorName }} | ||
steps: | ||
- name: Checkout infrastructure | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: main | ||
repository: equinor/robotics-infrastructure | ||
ssh-key: ${{ secrets.DeployKey }} | ||
|
||
- name: Update image in file | ||
run: | | ||
LINE_NUMBERS=($(grep -n "${{ inputs.Registry }}/${{ inputs.ImageName }}" k8s_kustomize/overlays/${{ inputs.Environment }}/kustomization.yaml | cut -d ':' -f 1)) | ||
for line_number in "${LINE_NUMBERS[@]}" | ||
do | ||
TAG_LINE_NUMBER=$((line_number+1)) | ||
sed -i "${TAG_LINE_NUMBER} s/newTag:.*/newTag: ${{ inputs.Tag }}/" "k8s_kustomize/overlays/${{ inputs.Environment }}/kustomization.yaml" | ||
done | ||
- name: Update infrastructure in GitHub | ||
run: | | ||
git config --global user.email "${EMAIL}" | ||
git config --global user.name "GitHub Actions (${NAME})" | ||
git add k8s_kustomize/overlays/${{ inputs.Environment }}/kustomization.yaml | ||
git commit --message "GHA: Update Isar-Exr in ${{ inputs.Environment }} (${{ inputs.Tag }})" || true | ||
git push |