-
Notifications
You must be signed in to change notification settings - Fork 28
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
3 changed files
with
167 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 ghcr for Development | ||
needs: [get-short-sha, trigger-github-deployment] | ||
uses: ./.github/workflows/publish_component.yml | ||
with: | ||
Registry: ghcr.io | ||
ImageName: ${{ github.repository }} | ||
Tag: ${{ needs.get-short-sha.outputs.tag }} | ||
secrets: | ||
RegistryUsername: ${{ github.actor }} | ||
RegistryPassword: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
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: ghcr.io | ||
ImageName: ${{ github.repository }} | ||
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,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,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-Robot in ${{ inputs.Environment }} (${{ inputs.Tag }})" || true | ||
git push |