Skip to content

Commit 59681c6

Browse files
Merge pull request #18 from mozilla/build-img
Build and Push to GCR
2 parents d5f84bc + 38f235a commit 59681c6

File tree

3 files changed

+109
-47
lines changed

3 files changed

+109
-47
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
**/*.py @mozilla/jbi-reviewers
1+
* @mozilla/jbi-reviewers

.github/workflows/build-image.yaml

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build Docker image
22

3-
on: [ push, pull_request ]
3+
on: pull_request
44

55
jobs:
66
prepare:
@@ -24,11 +24,13 @@ jobs:
2424
fi
2525
env:
2626
version_pattern: "tags\\/v[0-9]+\\.[0-9]+\\.[0-9]+"
27-
28-
2927
build-image:
3028
runs-on: ubuntu-latest
3129
needs: prepare
30+
environment:
31+
name: dev
32+
outputs:
33+
BUILD_TAG: ${{ steps.build-push.outputs.build-tag }}
3234

3335
steps:
3436
- name: Echo tag
@@ -38,41 +40,55 @@ jobs:
3840
run: |
3941
echo "Building an image with the following tag:"
4042
echo $IMAGE_TAG
43+
4144
- name: Checkout
4245
uses: actions/checkout@v2
4346

44-
# - name: Configure AWS Credentials
45-
# uses: aws-actions/configure-aws-credentials@v1
46-
# id: configure-aws-creds
47-
# env:
48-
# AWS_REGION: us-west-2
49-
# with:
50-
# aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
51-
# aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
52-
# aws-region: ${{ env.AWS_REGION }}
53-
#
54-
# - name: Login to Amazon ECR
55-
# id: login-ecr
56-
# uses: aws-actions/amazon-ecr-login@v1
57-
#
58-
# - name: Build and push to ECR
59-
# id: build-push
60-
# env:
61-
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
62-
# ECR_REPOSITORY: jira-bugzilla-integration
63-
# IMAGE_TAG: ${{ needs.prepare.outputs.FULL_IMAGE_TAG }}
64-
# run: |
65-
# printf '{\n "commit": "%s",\n "version": "%s",\n "image_tag": "%s",\n "source": "%s",\n "build": "%s"\n}\n' \
66-
# "$GITHUB_SHA" \
67-
# "$GITHUB_REF" \
68-
# "$IMAGE_TAG" \
69-
# "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
70-
# "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > ./version.json
71-
# docker build --file infra/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
72-
# docker image tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
73-
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
74-
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
75-
# - name: Logut of Amazon ECR
76-
# if: always()
77-
# run: |
78-
# docker logout ${{ steps.login-ecr.outputs.registry }}
47+
- name: Login to GCR
48+
uses: docker/login-action@v1
49+
with:
50+
registry: gcr.io
51+
username: _json_key
52+
password: ${{ secrets.GCP_CREDENTIALS }}
53+
54+
- name: Build and push to GCR
55+
id: build-push
56+
env:
57+
GCR_REGISTRY: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}/${{ secrets.GCP_GCR_REPO }}
58+
IMAGE_TAG: ${{ needs.prepare.outputs.FULL_IMAGE_TAG }}
59+
run: |
60+
printf '{\n "commit": "%s",\n "version": "%s",\n "image_tag": "%s",\n "source": "%s",\n "build": "%s"\n}\n' \
61+
"$GITHUB_SHA" \
62+
"$GITHUB_REF" \
63+
"$IMAGE_TAG" \
64+
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
65+
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > ./version.json
66+
docker build --file infra/Dockerfile -t $GCR_REGISTRY:$IMAGE_TAG .
67+
docker image tag $GCR_REGISTRY:$IMAGE_TAG $GCR_REGISTRY:latest
68+
docker push $GCR_REGISTRY:$IMAGE_TAG
69+
docker push $GCR_REGISTRY:latest
70+
echo "::set-output name=build-tag::$IMAGE_TAG"
71+
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

README.md

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,58 @@
1+
![build badge](https://github.com/mozilla/jira-bugzilla-integration/actions/workflows/build-image.yaml/badge.svg)
2+
![test badge](https://github.com/mozilla/jira-bugzilla-integration/actions/workflows/test-build.yaml/badge.svg)
3+
14
# Jira Bugzilla Integration (JBI)
2-
System to sync bugs and issues
5+
System to sync Bugzilla bugs to Jira issues.
6+
7+
### Caveats
8+
- The system accepts webhook events from Bugzilla
9+
- Bugs' whiteboard tags are used to determine if they should be synchronized or ignored
10+
- The events are transformed into Jira issues
11+
- The system sets the `see_also` field of the Bugzilla bug with the URL to the Jira issue
12+
13+
## Action Configuration
14+
The system reads the action configuration from a YAML file, one per environment. Each entry controls the synchronization between Bugzilla tickets with Jira issues.
15+
16+
17+
Below is a full example of an action configuration:
18+
```yaml
19+
action: src.jbi.whiteboard_actions.default
20+
contact: [[email protected]]
21+
description: example configuration
22+
enabled: true
23+
parameters:
24+
jira_project_key: EXMPL
25+
whiteboard_tag: example
26+
```
27+
28+
A bit more about the different fields...
29+
- `action` (optional)
30+
- string
31+
- default: [src.jbi.whiteboard_actions.default](src/jbi/whiteboard_actions/default.py)
32+
- The specified Python module must be available in the `PYTHONPATH`
33+
- `contact`
34+
- list of strings
35+
- If an issue arises with the workflow, communication will be established with these contacts
36+
- Please enter the contact information for one or more stakeholders
37+
- `description`
38+
- string
39+
- Please enter a description; for example, team name or project use-case.
40+
- `enabled` (optional)
41+
- bool [true, false]
42+
- default: false
43+
- If false, matching events will not be synchronized
44+
- `parameters` (optional)
45+
- dict
46+
- default: {}
47+
- The parameters will be validated to ensure the selected action accepts the specified values
48+
- The [default action](src/jbi/whiteboard_actions/default.py) expects both the `whiteboard_tag` and `jira_project_key` fields
49+
50+
51+
52+
[View 'dev' configurations here.](config/config.dev.yaml)
353

4-
## Self-Service
54+
[View 'prod' configurations here.](config/config.prod.yaml)
555

6-
If you're interested in using the default action;
7-
the process is simple to enabling a new downstream
8-
project. [...read more here.](src/jbi/whiteboard_tags/README.md)
956

10-
If you're looking for a unique capability for your
11-
team's data flow; you can add your own python methods
12-
and functionality. [...read more here.](src/jbi/whiteboard_actions/README.md)
57+
### Custom Actions
58+
If you're looking for a unique capability for your team's data flow, you can add your own python methods and functionality[...read more here.](src/jbi/whiteboard_actions/README.md)

0 commit comments

Comments
 (0)