-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (95 loc) · 5.01 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Docker Image CI for GHCR
on:
push:
tags:
- "*"
jobs:
build_and_push_test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io
- name: Get the tag name
id: tag
run: echo "::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}"
- name: Build and Push Test Image
env:
VITE_PRODUCTION_BASE_URL: "https://scienceprojects-test.dbca.wa.gov.au/"
VITE_PRODUCTION_BACKEND_API_URL: "https://scienceprojects-test.dbca.wa.gov.au/api/v1/"
VITE_PRODUCTION_PROFILES_BASE_URL: "https://profiles-test.dbca.wa.gov.au/"
VITE_SPMS_VERSION: ${{ steps.tag.outputs.TAG_NAME }}
run: |
docker build . --build-arg VITE_SPMS_VERSION=$VITE_SPMS_VERSION --build-arg VITE_PRODUCTION_PROFILES_BASE_URL=$VITE_PRODUCTION_PROFILES_BASE_URL --build-arg VITE_PRODUCTION_BASE_URL=$VITE_PRODUCTION_BASE_URL --build-arg VITE_PRODUCTION_BACKEND_API_URL=$VITE_PRODUCTION_BACKEND_API_URL --tag ghcr.io/dbca-wa/science-projects-client:test${{ steps.tag.outputs.TAG_NAME }}
docker push ghcr.io/dbca-wa/science-projects-client:test${{ steps.tag.outputs.TAG_NAME }}
docker tag ghcr.io/dbca-wa/science-projects-client:test${{ steps.tag.outputs.TAG_NAME }} ghcr.io/dbca-wa/science-projects-client:test
docker push ghcr.io/dbca-wa/science-projects-client:test
build_and_push_migration:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io
- name: Get the tag name
id: tag
run: echo "::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}"
- name: Build and Push Migration Image
env:
VITE_PRODUCTION_BASE_URL: "https://scienceprojects-migrated.dbca.wa.gov.au/"
VITE_PRODUCTION_BACKEND_API_URL: "https://scienceprojects-migrated.dbca.wa.gov.au/api/v1/"
VITE_PRODUCTION_PROFILES_BASE_URL: "https://profiles-migrated.dbca.wa.gov.au/"
VITE_SPMS_VERSION: ${{ steps.tag.outputs.TAG_NAME }}
run: |
docker build . --build-arg VITE_SPMS_VERSION=$VITE_SPMS_VERSION --build-arg VITE_PRODUCTION_PROFILES_BASE_URL=$VITE_PRODUCTION_PROFILES_BASE_URL --build-arg VITE_PRODUCTION_BASE_URL=$VITE_PRODUCTION_BASE_URL --build-arg VITE_PRODUCTION_BACKEND_API_URL=$VITE_PRODUCTION_BACKEND_API_URL --tag ghcr.io/dbca-wa/science-projects-client:migration
docker push ghcr.io/dbca-wa/science-projects-client:migration
build_production:
runs-on: ubuntu-latest
outputs:
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io
- name: Get the tag name
id: tag
run: echo "::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}"
- name: Build Production Image
env:
VITE_PRODUCTION_BASE_URL: "https://scienceprojects.dbca.wa.gov.au/"
VITE_PRODUCTION_BACKEND_API_URL: "https://scienceprojects.dbca.wa.gov.au/api/v1/"
VITE_PRODUCTION_PROFILES_BASE_URL: "https://profiles.dbca.wa.gov.au/"
VITE_SPMS_VERSION: ${{ steps.tag.outputs.TAG_NAME }}
run: |
docker build . --build-arg VITE_SPMS_VERSION=$VITE_SPMS_VERSION --build-arg VITE_PRODUCTION_PROFILES_BASE_URL=$VITE_PRODUCTION_PROFILES_BASE_URL --build-arg VITE_PRODUCTION_BASE_URL=$VITE_PRODUCTION_BASE_URL --build-arg VITE_PRODUCTION_BACKEND_API_URL=$VITE_PRODUCTION_BACKEND_API_URL --tag ghcr.io/dbca-wa/science-projects-client:${{ steps.tag.outputs.TAG_NAME }}
- name: Save Docker Image as Artifact
uses: actions/upload-artifact@v3
with:
name: production-image
path: |
$(docker save ghcr.io/dbca-wa/science-projects-client:${{ steps.tag.outputs.TAG_NAME }} | tee /tmp/production-image.tar)
push_production:
needs: build_production
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker
run: docker login --username idabblewith --password ${{ secrets.GH_PAT }} ghcr.io
- name: Download Docker Image Artifact
uses: actions/download-artifact@v3
with:
name: production-image
- name: Load Docker Image
run: |
docker load -i production-image.tar
- name: Push Production Image
env:
TAG_NAME: ${{ needs.build_production.outputs.TAG_NAME }}
run: |
echo "Pushing image with tag: $TAG_NAME"
docker push ghcr.io/dbca-wa/science-projects-client:${TAG_NAME}
docker tag ghcr.io/dbca-wa/science-projects-client:${TAG_NAME} ghcr.io/dbca-wa/science-projects-client:latest
docker push ghcr.io/dbca-wa/science-projects-client:latest