Skip to content

Commit cc21253

Browse files
authored
Create ci.yml
1 parent 9947d18 commit cc21253

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: release-gtp2chebi-update ci
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
push:
10+
branches:
11+
- main
12+
13+
permissions:
14+
id-token: write
15+
contents: read
16+
17+
jobs:
18+
lint:
19+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
20+
runs-on: ubuntu-latest
21+
env:
22+
REPO_DIR: /opt/release-gtp2chebi-update
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Run lint
27+
run: |
28+
docker build --build-arg REPO_DIR="$REPO_DIR" --target setup-env -t lint-image .
29+
docker run --name lint-container lint-image
30+
31+
- name: Display lint errors
32+
if: failure()
33+
run: |
34+
docker cp lint-container:"$REPO_DIR"/lint.log .
35+
while IFS= read -r LINT_MSG; do echo "::warning::${LINT_MSG}"; done < lint.log
36+
exit 1
37+
38+
docker-build:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- uses: docker/setup-buildx-action@v3
44+
45+
- uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
file: Dockerfile
49+
tags: tmp-tag
50+
outputs: type=docker,dest=/tmp/image.tar
51+
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: image-artifact
55+
path: /tmp/image.tar
56+
57+
docker-push:
58+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
59+
needs: docker-build
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/download-artifact@v4
63+
with:
64+
name: image-artifact
65+
path: /tmp
66+
67+
- id: get-hash
68+
run: |
69+
FULL_SHA=${{ github.sha }}
70+
echo "SHORT_SHA=${FULL_SHA:0:7}" >> $GITHUB_OUTPUT
71+
72+
- env:
73+
AWS_REGION: us-east-1
74+
uses: aws-actions/configure-aws-credentials@v4
75+
with:
76+
role-to-assume: ${{ vars.AWS_ROLE }}
77+
aws-region: ${{ env.AWS_REGION }}
78+
79+
- id: login-ecr
80+
uses: aws-actions/amazon-ecr-login@v2
81+
with:
82+
registry-type: public
83+
84+
- env:
85+
AWS_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
86+
AWS_REGISTRY_ALIAS: reactome
87+
AWS_REPO: release-gtp2chebi-update
88+
IMG_TAG: ${{ steps.get-hash.outputs.SHORT_SHA }}
89+
run: |
90+
AWS_URI=$AWS_REGISTRY/$AWS_REGISTRY_ALIAS/$AWS_REPO
91+
docker load --input /tmp/image.tar
92+
docker tag tmp-tag $AWS_URI:latest
93+
docker push $AWS_URI:latest
94+
docker tag $AWS_URI:latest $AWS_URI:$IMG_TAG
95+
docker push $AWS_URI:$IMG_TAG
96+

0 commit comments

Comments
 (0)