Skip to content

Commit 7c68250

Browse files
committed
push docker image on release
1 parent 679e48f commit 7c68250

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@ jobs:
1212
steps:
1313
- name: checkout code
1414
uses: actions/checkout@v2
15+
1516
- name: run tests
1617
run: ./gradlew test
18+
1719
- name: build
1820
run: ./gradlew releaseBundle
21+
1922
- name: get project info
2023
id: get_project_info
2124
run: |
2225
echo ::set-output name=PROJECT::$(basename `pwd`)
26+
echo ::set-output name=PROJECT_KEBAB::$(basename `pwd` | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\L\2/g')
2327
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
28+
2429
- name: create release
2530
id: create_release
2631
uses: actions/create-release@v1
@@ -31,6 +36,7 @@ jobs:
3136
release_name: Release ${{ github.ref }}
3237
draft: false
3338
prerelease: false
39+
3440
- name: upload release asset
3541
id: upload-release-asset
3642
uses: actions/upload-release-asset@v1
@@ -41,6 +47,36 @@ jobs:
4147
asset_path: ./build/distributions/${{ steps.get_project_info.outputs.PROJECT }}-${{ steps.get_project_info.outputs.VERSION }}.zip
4248
asset_name: ${{ steps.get_project_info.outputs.PROJECT }}-${{ steps.get_project_info.outputs.VERSION }}.zip
4349
asset_content_type: application/zip
50+
51+
- name: build docker image
52+
id: build-docker-image
53+
run: |
54+
docker build -t gcr.io/cloud-armory/${{ steps.get_project_info.outputs.PROJECT_KEBAB }}:${{ steps.get_project_info.outputs.VERSION }} -f ./Dockerfile .
55+
docker save -o ./${{ steps.get_project_info.outputs.PROJECT_KEBAB }}-${{ steps.get_project_info.outputs.VERSION }}.tar gcr.io/cloud-armory/${{ steps.get_project_info.outputs.PROJECT_KEBAB }}:${{ steps.get_project_info.outputs.VERSION }}
56+
57+
- name: upload image to release
58+
id: upload-image-to-release
59+
uses: actions/upload-release-asset@v1
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
with:
63+
upload_url: ${{ steps.create_release.outputs.upload_url }}
64+
asset_path: ./${{ steps.get_project_info.outputs.PROJECT_KEBAB }}-${{ steps.get_project_info.outputs.VERSION }}.tar
65+
asset_name: ${{ steps.get_project_info.outputs.PROJECT_KEBAB }}-${{ steps.get_project_info.outputs.VERSION }}.tar
66+
asset_content_type: application/zip
67+
4468
- name: add release to plugin repo
4569
run: |
46-
curl -XPOST -u "${{ secrets.USERNAME }}:${{ secrets.TOKEN }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/spinnaker-plugin-examples/examplePluginRepository/dispatches --data "{\"event_type\": \"onPluginRelease\", \"client_payload\": {\"org\": \"spinnaker-plugin-examples\", \"repo\": \"${{ steps.get_project_info.outputs.PROJECT }}\", \"released\": $(cat build/distributions/plugin-info.json)}}"
70+
curl -XPOST -u "${{ secrets.USERNAME }}:${{ secrets.TOKEN }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/spinnaker-plugin-examples/examplePluginRepository/dispatches --data "{\"event_type\": \"onPluginRelease\", \"client_payload\": {\"org\": \"spinnaker-plugin-examples\", \"repo\": \"${{ steps.get_project_info.outputs.PROJECT }}\", \"released\": $(cat build/distributions/plugin-info.json)}}"
71+
72+
- name: setup gcloud
73+
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
74+
with:
75+
project_id: cloud-armory
76+
service_account_key: ${{ secrets.GCP_KEY }}
77+
export_default_credentials: true
78+
79+
- name: push image to registry
80+
run: |
81+
gcloud auth configure-docker -q
82+
docker push gcr.io/cloud-armory/${{ steps.get_project_info.outputs.PROJECT_KEBAB }}:${{ steps.get_project_info.outputs.VERSION }}

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM scratch
2+
3+
COPY build/distributions/ /plugins

0 commit comments

Comments
 (0)