Created
May 8, 2022 10:02
-
-
Save subudear/f02a6d362204c439983176fb7286d50c to your computer and use it in GitHub Desktop.
build pipeline to upload image to aws ecr
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
trigger: | |
- main | |
pool: | |
name: Self-Hosted-Agent | |
variables: | |
- group: AWS | |
stages: | |
- stage: Build | |
dependsOn: [] # This will remove implicit dependency and run in parallel with the stage: Tests above | |
jobs: | |
- job: | |
workspace: | |
clean: all | |
displayName: Build the application | |
steps: | |
- task: Go@0 | |
displayName: "Go Get" | |
inputs: | |
command: 'get' | |
arguments: '-d' | |
workingDirectory: '$(System.DefaultWorkingDirectory)' | |
- task: Go@0 | |
displayName: "Go Build" | |
inputs: | |
command: 'build' | |
workingDirectory: '$(System.DefaultWorkingDirectory)' | |
- task: replacetokens@5 | |
displayName: 'Replace image version in deployment.yaml' | |
inputs: | |
rootDirectory: '$(System.DefaultWorkingDirectory)' | |
targetFiles: | | |
**/fargate/*.json | |
**/hello-world.go | |
tokenPrefix: '#{' | |
tokenSuffix: '}#' | |
- task: CopyFiles@2 | |
inputs: | |
SourceFolder: '$(System.DefaultWorkingDirectory)/fargate' | |
Contents: 'fargate-task-definition.json' | |
TargetFolder: '$(Build.ArtifactStagingDirectory)' | |
- task: PublishBuildArtifacts@1 | |
inputs: | |
artifactName: drop | |
- task: Docker@2 | |
displayName: Build an image | |
inputs: | |
command: build | |
dockerfile: '$(System.DefaultWorkingDirectory)/Dockerfile' | |
buildContext: '$(System.DefaultWorkingDirectory)' | |
repository: $(AWS_ECR_MAGE_URI) | |
- task: ECRPushImage@1 | |
inputs: | |
awsCredentials: 'AWS_Service' | |
regionName: $(AWS_REGION) | |
imageSource: 'imagename' | |
sourceImageName: $(AWS_ECR_MAGE_URI) | |
sourceImageTag: $(Build.BuildId) | |
pushTag: $(Build.BuildId) | |
repositoryName: $(AWS_ECR_REPOSITORY_NAME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment