Skip to content

Commit 3ff2b79

Browse files
Merge pull request #27 from mozilla/proj-update
Updating pre-commit, workflows, and readme.
2 parents 59681c6 + e2110f5 commit 3ff2b79

File tree

6 files changed

+133
-28
lines changed

6 files changed

+133
-28
lines changed

.github/workflows/build-image.yaml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,3 @@ jobs:
6969
docker push $GCR_REGISTRY:latest
7070
echo "::set-output name=build-tag::$IMAGE_TAG"
7171
echo "::debug::Set the build-tag output as $IMAGE_TAG"
72-
73-
deploy-image:
74-
runs-on: ubuntu-latest
75-
needs: build-image
76-
environment:
77-
name: dev
78-
79-
steps:
80-
- id: auth
81-
uses: google-github-actions/auth@v0
82-
with:
83-
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
84-
85-
- name: Deploy to Cloud Run
86-
uses: google-github-actions/deploy-cloudrun@v0
87-
with:
88-
service: ${{ secrets.GCP_APP_NAME }}
89-
image: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}/${{ secrets.GCP_GCR_REPO }}:${{ needs.build-image.outputs.BUILD_TAG }}
90-
region: ${{ secrets.GCP_REGION }}
91-
secrets: |
92-
JIRA_PASSWORD=JIRA_PASSWORD:latest
93-
JIRA_USERNAME=JIRA_USERNAME:latest
94-
BUGZILLA_API_KEY=BUGZILLA_API_KEY:latest

.github/workflows/deploy-build.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Build and Deploy Docker image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
prepare:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
FULL_IMAGE_TAG: ${{ steps.tag.outputs.tag }}
12+
steps:
13+
- name: Set Tag
14+
id: tag
15+
run: |
16+
export CI_COMMIT_SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-8)
17+
echo $CI_COMMIT_SHORT_SHA;
18+
echo ${GITHUB_REF##*/};
19+
echo $version_pattern;
20+
if [[ ${GITHUB_REF} =~ $version_pattern ]]; then
21+
echo "::set-output name=tag::${GITHUB_REF##*/}"
22+
elif [ ${GITHUB_REF##*/} = "main" ]; then
23+
echo "::set-output name=tag::stg-$CI_COMMIT_SHORT_SHA"
24+
else
25+
echo "::set-output name=tag::$CI_COMMIT_SHORT_SHA"
26+
fi
27+
env:
28+
version_pattern: "tags\\/v[0-9]+\\.[0-9]+\\.[0-9]+"
29+
build-image:
30+
runs-on: ubuntu-latest
31+
needs: prepare
32+
environment:
33+
name: dev
34+
outputs:
35+
BUILD_TAG: ${{ steps.build-push.outputs.build-tag }}
36+
37+
steps:
38+
- name: Echo tag
39+
id: echotag
40+
env:
41+
IMAGE_TAG: ${{ needs.prepare.outputs.FULL_IMAGE_TAG }}
42+
run: |
43+
echo "Building an image with the following tag:"
44+
echo $IMAGE_TAG
45+
46+
- name: Checkout
47+
uses: actions/checkout@v2
48+
49+
- name: Login to GCR
50+
uses: docker/login-action@v1
51+
with:
52+
registry: gcr.io
53+
username: _json_key
54+
password: ${{ secrets.GCP_CREDENTIALS }}
55+
56+
- name: Build and push to GCR
57+
id: build-push
58+
env:
59+
GCR_REGISTRY: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}/${{ secrets.GCP_GCR_REPO }}
60+
IMAGE_TAG: ${{ needs.prepare.outputs.FULL_IMAGE_TAG }}
61+
run: |
62+
printf '{\n "commit": "%s",\n "version": "%s",\n "image_tag": "%s",\n "source": "%s",\n "build": "%s"\n}\n' \
63+
"$GITHUB_SHA" \
64+
"$GITHUB_REF" \
65+
"$IMAGE_TAG" \
66+
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
67+
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > ./version.json
68+
docker build --file infra/Dockerfile -t $GCR_REGISTRY:$IMAGE_TAG .
69+
docker image tag $GCR_REGISTRY:$IMAGE_TAG $GCR_REGISTRY:latest
70+
docker push $GCR_REGISTRY:$IMAGE_TAG
71+
docker push $GCR_REGISTRY:latest
72+
echo "::set-output name=build-tag::$IMAGE_TAG"
73+
echo "::debug::Set the build-tag output as $IMAGE_TAG"
74+
75+
deploy-image:
76+
runs-on: ubuntu-latest
77+
needs: build-image
78+
environment:
79+
name: dev
80+
81+
steps:
82+
- id: auth
83+
uses: google-github-actions/auth@v0
84+
with:
85+
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
86+
87+
- name: Deploy to Cloud Run
88+
uses: google-github-actions/deploy-cloudrun@v0
89+
with:
90+
service: ${{ secrets.GCP_APP_NAME }}
91+
image: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}/${{ secrets.GCP_GCR_REPO }}:${{ needs.build-image.outputs.BUILD_TAG }}
92+
region: ${{ secrets.GCP_REGION }}
93+
secrets: |
94+
JIRA_PASSWORD=JIRA_PASSWORD:latest
95+
JIRA_USERNAME=JIRA_USERNAME:latest
96+
BUGZILLA_API_KEY=BUGZILLA_API_KEY:latest

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
exclude: |
2+
(?x)^(
3+
.*/gunicorn_conf.py|
4+
.*/test_gunicorn_conf.py
5+
)$
16
repos:
27
- repo: local
38
hooks:
@@ -56,6 +61,11 @@ repos:
5661
args: ["--recursive", "--settings-path", "./pyproject.toml", "."]
5762
language: system
5863
types: [python]
64+
exclude: |
65+
(?x)^(
66+
.*/gunicorn_conf.py|
67+
.*/test_gunicorn_conf.py
68+
)$
5969
- repo: local
6070
hooks:
6171
- id: black

.secrets.baseline

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"custom_plugin_paths": [],
33
"exclude": {
4-
"files": null,
4+
"files": "^.secrets.baseline$",
55
"lines": null
66
},
7-
"generated_at": "2022-02-04T19:26:47Z",
7+
"generated_at": "2022-03-18T00:00:55Z",
88
"plugins_used": [
99
{
1010
"name": "AWSKeyDetector"
@@ -59,11 +59,31 @@
5959
}
6060
],
6161
"results": {
62+
".github/workflows/deploy-build.yaml": [
63+
{
64+
"hashed_secret": "24b04b46d769e6f6b8d10c943738ac5c968dea1c",
65+
"is_verified": false,
66+
"line_number": 94,
67+
"type": "Secret Keyword"
68+
},
69+
{
70+
"hashed_secret": "1481d0a0ceb16ea4672fed76a0710306eb9f3a33",
71+
"is_verified": false,
72+
"line_number": 96,
73+
"type": "Secret Keyword"
74+
},
75+
{
76+
"hashed_secret": "30a1dfa6d09c177dcd147a5f31a5627becd96b23",
77+
"is_verified": false,
78+
"line_number": 96,
79+
"type": "Secret Keyword"
80+
}
81+
],
6282
"poetry.lock": [
6383
{
64-
"hashed_secret": "a3c8e175e20ee103a0aafa92378200de0583c54b",
84+
"hashed_secret": "d97b148b47121abb687af133c28a3932202426b0",
6585
"is_verified": false,
66-
"line_number": 542,
86+
"line_number": 899,
6787
"type": "Hex High Entropy String"
6888
}
6989
]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
![build badge](https://github.com/mozilla/jira-bugzilla-integration/actions/workflows/build-image.yaml/badge.svg)
22
![test badge](https://github.com/mozilla/jira-bugzilla-integration/actions/workflows/test-build.yaml/badge.svg)
3+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
34

45
# Jira Bugzilla Integration (JBI)
56
System to sync Bugzilla bugs to Jira issues.

tests/unit/test_gunicorn_conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from pydantic import ValidationError
21
import pytest
2+
from pydantic import ValidationError
3+
34
from infra.gunicorn_conf import GunicornSettings
45

56

0 commit comments

Comments
 (0)