-
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.
[WIP] Implement reusable workflow for acr (#14)
* Implement reusable workflow for acr * comment ACR_NAME out * add readme * should work now * fix another var * add application_name * bump checkout version
- Loading branch information
1 parent
eea4274
commit 07981c1
Showing
4 changed files
with
81 additions
and
3 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,72 @@ | ||
name: Build and push docker image to Azure Container Registry | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
APPLICATION_NAME: | ||
required: true | ||
type: string | ||
ACR_NAME: | ||
required: true | ||
type: string | ||
AZURE_CLIENT_ID: | ||
required: true | ||
type: string | ||
AZURE_TENANT_ID: | ||
required: true | ||
type: string | ||
AZURE_SUBSCRIPTION_ID: | ||
required: true | ||
type: string | ||
DOCKERFILE_NAME: | ||
required: false | ||
type: string | ||
DOCKERFILE_PATH: | ||
required: false | ||
type: string | ||
ENVIRONMENT: | ||
required: true | ||
type: string | ||
REGISTRY_URL: | ||
required: true | ||
type: string | ||
RETAG: | ||
required: false | ||
type: boolean | ||
default: true | ||
BUILD_ARG: | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Az CLI login | ||
uses: azure/login@v2 | ||
with: | ||
client-id: ${{ inputs.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ inputs.AZURE_TENANT_ID }} | ||
subscription-id: ${{ inputs.AZURE_SUBSCRIPTION_ID }} | ||
- name: Login to ACR | ||
run: | | ||
az acr login --name ${{ inputs.ACR_NAME }} | ||
- name: Build and push container image | ||
if: ${{ (inputs.ENVIRONMENT != 'prod' && (inputs.RETAG == true || inputs.RETAG == 'true')) || (inputs.RETAG == false || inputs.RETAG == 'false') }} | ||
working-directory: ${{ inputs.DOCKERFILE_PATH }} | ||
run: | | ||
docker build -f ${{ inputs.DOCKERFILE_NAME }} \ | ||
-t ${{ inputs.REGISTRY_URL }}/${{ inputs.APPLICATION_NAME }}:$GITHUB_SHA \ | ||
. ${{ inputs.BUILD_ARG }} | ||
docker push -a ${{ inputs.REGISTRY_URL }}/${{ inputs.APPLICATION_NAME }} | ||
- name: Retag and push container image | ||
if: ${{ inputs.ENVIRONMENT == 'prod' && (inputs.RETAG == true || inputs.RETAG == 'true') }} | ||
run: | | ||
docker pull ${{ inputs.REGISTRY_URL }}/${{ inputs.APPLICATION_NAME }}:$GITHUB_SHA | ||
docker tag ${{ inputs.REGISTRY_URL }}/${{ inputs.APPLICATION_NAME }}:$GITHUB_SHA ${{ inputs.REGISTRY_URL }}/${{ inputs.APPLICATION_NAME }}:${{ github.ref_name }} | ||
docker push ${{ inputs.REGISTRY_URL }}/${{ inputs.APPLICATION_NAME }}:${{ github.ref_name }} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Build | ||
name: Build and push docker image to Azure Container Registry | ||
|
||
on: | ||
workflow_call: | ||
|
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
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 |
---|---|---|
@@ -1 +1,7 @@ | ||
# github-workflows | ||
This repository contains a collection of reusable github actions workflows to be used by Cloudkite's clients | ||
|
||
* `build-and-push-image-to-acr.yml` - Build and push docker image to Azure Container Registry | ||
* `build-docker-push-to-acr.yml` - Build and push docker image to Elastic Container Registry | ||
* `commit-to-helm-chart-cronjobs.yml` - Commit and push new image tag for a cronjob (standard-app.cronjobs.$CRONJOB_NAME.tag) | ||
* `commit-to-helm-chart.yml` - Commit and push new global image tag for the whole chart (standard-app.tag) |