Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Commit 3e7dc31

Browse files
rust_workflow: added yaml
A workflow to build the rust branch with tags rust-latest, and tag rust-{{sha}}. This way we can differentiate between the python and rust builds
1 parent 2720fe7 commit 3e7dc31

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- rust
7+
workflow_dispatch:
8+
9+
env:
10+
REGISTRY: europe-north1-docker.pkg.dev/${{ secrets.GAR_PROJECT_ID }}/microdata-docker
11+
IMAGE: metadata-service
12+
13+
jobs:
14+
test:
15+
name: cargo test
16+
runs-on: ubuntu-latest
17+
if: github.event_name == 'pull_request'
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
ref: rust
22+
- uses: dtolnay/rust-toolchain@stable
23+
- run: cargo test --all-features
24+
25+
build:
26+
runs-on: ubuntu-latest
27+
needs: test
28+
permissions:
29+
contents: read
30+
id-token: write
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
ref: rust
36+
37+
- name: Authenticate to Google Cloud
38+
id: auth
39+
uses: google-github-actions/auth@v1.1.1
40+
with:
41+
workload_identity_provider: "projects/${{ secrets.GAR_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions"
42+
service_account: "gh-actions-microdata@${{ secrets.GAR_PROJECT_ID }}.iam.gserviceaccount.com"
43+
token_format: access_token
44+
45+
- name: Set up Docker Buildx
46+
id: buildx
47+
uses: docker/setup-buildx-action@v2
48+
49+
- name: Login to Artifact Registry
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: "oauth2accesstoken"
54+
password: "${{ steps.auth.outputs.access_token }}"
55+
56+
- name: Extract build metadata for Docker
57+
id: build_metadata
58+
uses: docker/metadata-action@v5
59+
with:
60+
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
61+
tags: |
62+
type=raw,value=rust-{{sha}}
63+
type=raw,value=rust-latest
64+
65+
- name: Build and push docker image to Artifact Registry
66+
uses: docker/build-push-action@v4
67+
with:
68+
context: .
69+
provenance: false
70+
file: Dockerfile
71+
push: true
72+
tags: ${{ steps.build_metadata.outputs.tags }}
73+
labels: ${{ steps.build_metadata.outputs.labels }}
74+
build-args: |
75+
COMMIT_ID=${{ github.sha }}
76+
77+
integration-test:
78+
name: Run Integration test
79+
runs-on: ubuntu-latest
80+
needs: build
81+
permissions:
82+
contents: read
83+
id-token: write
84+
85+
steps:
86+
- name: Call workflow
87+
uses: actions/github-script@v7
88+
with:
89+
github-token: ${{ secrets.INTEGRATION_TEST_PAT }}
90+
script: |
91+
await github.rest.actions.createWorkflowDispatch({
92+
owner: 'statisticsnorway',
93+
repo: '${{ secrets.INTEGRATION_TEST_REPO }}',
94+
workflow_id: '${{ secrets.INTEGRATION_TEST_WORKFLOW }}.yaml',
95+
ref: 'main'
96+
})

0 commit comments

Comments
 (0)